Thread: Reading from a file

  1. #16
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    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 10: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
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    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

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-21-2008, 11:19 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12: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, 10:12 PM