Reading from a file

This is a discussion on Reading from a file within the C++ Programming forums, part of the General Programming Boards category; Oops, missed an include (my bad)! #include <vector> Edit: And do NOT!!!! do this: "#include <iostream.h>" Instead, do this: "#include ...

  1. #16
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Oops, missed an include (my bad)!

    #include <vector>

    Edit: And do NOT!!!! do this: "#include <iostream.h>"

    Instead, do this: "#include <iostream>"

    The first isn't legal C++, nor is it what you want. It's also totally unnecessary to include either, as <fstream> will probably include <iostream> itself.
    Last edited by Cat; 06-15-2003 at 11:21 AM.

  2. #17
    Registered User
    Join Date
    May 2003
    Posts
    148
    >>It's also totally unnecessary to include either, as <fstream> will probably include <iostream> itself.
    No,test with VS 2003.
    Nothing in the C++ Standard states that one standard includes another standard header.
    Every implementation has it's own rules.

  3. #18
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Hmm, you're right, VS .NET doesn't include <iostream>. I know it's always implementation defined, so you're right, for maximum portability you should explicitly include everything.

  4. #19
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    <fstream> will have already included basic_ostream and basic_istream, but should not have defined the symbols cout and cin.

    fstream = basic_fstream derives from basic_ifstream & basic_ofstream

    basic_ofstream derives basic_ostream
    basic_ifstream derives from basic_istream

    cout is an ostream (= basic_ostream)
    cin is an istream (= basic_istream)
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #20
    Registered User
    Join Date
    Nov 2002
    Posts
    48

    Talking

    It's working, thanks

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21