studio.h vs iostream

Jan 24, 2011 at 4:59pm
Hello,
I'm learning C++ in my Programming Methodology class. My professor is using the compiler directive #include <stdio.h>, but my book uses #include <iostream>. My professor's programs use totally different commands and syntax than my text book. Could someone please explain to me the difference between the two? Does one require different syntax than the other? For example, he uses things printf("real number: %3.3f\n", x) instead of the cout<< stuff, and I have no idea what the % sign or the f\n are for. If someone could find a list of corresponding commands for each one, I'd be set. Please help!
Thank you.
Jan 24, 2011 at 5:01pm
They are two different files with two different purposes. You can use them together or apart. Take a look here:
http://www.cplusplus.com/reference/iostream/
Jan 24, 2011 at 5:07pm
stdio.h is form c standard library, iostream is from c++ standard library. Note that if you want to use stdio.h in c++ programs it would be better to include cstdio instead.
As for printf, see http://www.cplusplus.com/reference/clibrary/cstdio/printf/

By the way, you have a typo in your title..
Jan 24, 2011 at 5:45pm
yap.. like hamsterman said, #include <stdio.h> i for C programming language, #include <iostream> is for c++... in c is printf and scanf, in c++ is cout and cout and cin :)))
Topic archived. No new replies allowed.