April 14th, 2003, 11:37 PM
What header file should I use?
When I write a piece of code in C i often ask myself what library should I use. Stdio or iostream? I will like to know your opinion releated with this problem or I will like to find out other libraries for reading from the keyboard and writing on the screen.
April 14th, 2003, 11:47 PM
Read the documentation for the functions you use and it should tell you which headers are required.
Seriously, if you're using C "open()" IO, stick to that. If you're using stdio "fopen()", stick to that (more portable anyway).
If you're using C++ and want to use *any* C++ IO, stick to that (cin, cout etc)
If you use a library like curses, use that exclusively.
Basically, don't mix & match, it will only cause tears down the line, particularly cross platform.
April 15th, 2003, 12:07 AM
that depends what you want to do, for righting text and organizing it i would suggest stdio, but using actual file io use iostream..
April 15th, 2003, 01:59 AM
you may have problems using iostream with c because its for c++,
funny though, i never tried including iostream in a c project, i just assumed it wouldn't work.
http://www.digitalmars.com check out their runtime library reference.
Hmm...theres something a little peculiar here. Oh i see what it is! the sentence is talking about itself! do you see that? what do you mean? sentences can\'t talk! No, but they REFER to things, and this one refers directly-unambigeously-unmistakably-to the very sentence which it is!
April 15th, 2003, 06:19 AM
It comes down to 1 thing, what language are you using?
If you are using C, use stdio and scanf(), printf(), fprintf(), etc. That is a C library and uses C functions.
If you are using C++, use iostream with cin, cout, etc... and fstream with istream, ostream, ... These are C++ libraries that use C++ classes.
\"When you say best friends, it means friends forever\" Brand New
\"Best friends means I pulled the trigger
Best friends means you get what you deserve\" Taking Back Sunday