oyu8201's blog

By oyu8201, history, 7 years ago, In English

I've been using iostream for c++14 for a long time. Would it be more simple if I switched to stdio.h?

  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it -18 Vote: I do not like it

I first learned iostream, but I'm pretty sure stdio.h would be more simple

»
7 years ago, # |
  Vote: I like it +10 Vote: I do not like it

Why would stdio be simpler?

iostream is very easy to use, and it's easy to make it faster by removing synchronization with the stdio library and untying std::cin and std::cout. In almost all cases, using iostream with these 2 optimizations will let your code pass the TL.

There are maybe 4 or 5 problems that I've solved that actually didn't pass with iostream. One of them is Problem J of the Arab Collegiate Programming Contest from 2010. That problem has almost 80MB of input files. I think even stdio didn't stand a chance there. I recall writing my own thing to read the input in 1KB blocks or something.

I also recall this problem: http://codeforces.com/gym/101102/problem/J I couldn't get it to pass with iostream, but stdio passed just fine.

This is pretty rare in my opinion though. Don't take it too seriously, it's one data point.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

iostream is more extensible ... If the data type is something different like pid_t ... You don't need to find the exact formate specifier for it. The disadvantage is that it is a little slower ... However there are ways to get around it.

P.S. — You can use cstdio ... It has all of the functions in stdio.h. I use cstdio when I use printf and scanf is C++ programs.