LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   difference between stdio.h and iostream.h? (https://www.linuxquestions.org/questions/linux-newbie-8/difference-between-stdio-h-and-iostream-h-758828/)

vendtagain 09-30-2009 11:42 PM

difference between stdio.h and iostream.h?
 
i used to iostream for output with c++, but I have been noticing stdio.h more common for output since iv started linux? is stdio more for C and iostream made for c++? or is it just a preference?

paulsm4 09-30-2009 11:52 PM

Hi -

Quote:

Q: is stdio more for C?
A: Yes

Q: and iostream made for c++?
A: Yes

Q: or is it just a preference?
A: Yes
ALSO:
Using "printf()" in C++ is sometimes frowned upon...
... but you simply *can't* use "cout" in C.

'Hope that helps

lutusp 10-01-2009 02:13 AM

Quote:

Originally Posted by vendtagain (Post 3702790)
i used to iostream for output with c++, but I have been noticing stdio.h more common for output since iv started linux? is stdio more for C and iostream made for c++? or is it just a preference?

It is not just a preference -- they refer to entirely different things:

Code:

# include <sdtio.h>

...

printf("There are %d bottles of beer on the wall\n",total);

Versus:

Code:

#include <oiostream>

...

std.cout << "There are " << total << " bottles of beer on the wall" << std.endl;

Completely different design and intention. By the way, in your programs don't mix the two I/O styles shown above -- use one or the other exclusively. Mixing them causes endless synchronization difficulties.


All times are GMT -5. The time now is 08:31 PM.