What header file should I use?
Results 1 to 5 of 5

Thread: What header file should I use?

  1. #1

    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.

  2. #2
    Senior Member
    Join Date
    Jan 2002
    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.

  3. #3
    Junior Member
    Join Date
    Apr 2003
    that depends what you want to do, for righting text and organizing it i would suggest stdio, but using actual file io use iostream..
    Tha all mity Rodent!

  4. #4
    Senior Member
    Join Date
    Jun 2002
    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!

  5. #5
    Senior Member
    Join Date
    Nov 2002
    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.
    Good luck!
    \"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
    Visit alastairgrant.ca

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts