Results 1 to 5 of 5

Thread: IO functions

  1. #1

    IO functions

    Hey guys:

    I've recently started hoarding C++ tutorials to get my info from various sources. One problem though: The Dev-Cpp tutorial uses the header stdio.h and printf(scanf) functions.

    Like one other tutorial I have follows this (and, honestly, I much prefer it). But the rest use another header in addition, iostream.h, which Dev-Cpp does not include (at least not under that name) and this command for IO: cout << / cin <<

    Note: Dev does include some sort of iostream, which is basically a reference to another header, but it doesn't seam to work with cout <<.

    I'm a newb (just re-stating the obvious). Which header works with what, and which is most common (function)

    Thanks
    \"I ONLY DRINK THE BLOOD OF MY ENEMIES....and maybe a strawberry yoohoo....and a...Pina Co-la-da!...
    If you like pina coladas....ugh!, gettin\' caught in the rain....ugh!\"
    -Sarge

  2. #2
    Antionline Herpetologist
    Join Date
    Aug 2001
    Posts
    1,165
    stdio.h, printf() and scanf() are all C functions. That doesn't mean you can't use them in C++, just that C++ provides alternatives. iostream.h, cin and cout are C++ only things. My version of Dev C++ does cin and cout fine, as should any C/C++ compiler.

    Cheers,
    cgkanchi
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog: http://biology000.blogspot.com

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    420
    I think of C++ as a superset of C. Everything that I can do in C can also be done in C++. That does not mean that everything I can do in C++ can be done in C. The tutorieals that use printf or scanf are valid for C++ even through they are C functions.

    Cheers,
    -D
    If you spend more on coffee than on IT security, you will be hacked. What\'s more, you deserve to be hacked.
    -- former White House cybersecurity adviser Richard Clarke

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    813
    With some compilers, however, it matters what the extension on the file is. Sometimes they won't be keen on even trying to interpret a .c file as anything other than c. So you might have an issue there, sometimes, if you're not careful.

    Other than that it has already been stated where the functions are. For gcc a lot of the basic [like scanf()/printf()] functions don't even need a header to be declared [although doing so ensures better portability]
    /\\

  5. #5
    Senior Member
    Join Date
    Dec 2001
    Posts
    134
    Try using either of the Stdio.h or iostream.h, i am not not sure, but can try.
    U get What U pay for.

Posting Permissions

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