Thread: file I/O

  1. #16
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by cmasri
    ms visual studio.net 2003
    Tried with this compiler
    Code:
    #include <iostream>
    #include <string>
    #include <fstream>
    
    void ListFileHDD(std::ifstream& fin)
    {
    	std::string line;
    	while (!fin.eof())
    	{
    		std::getline(fin,line);
    	}
    	std::cout<<line;
    }
    
    int main(void)
    {
    	std::ifstream fin("c:\\test");
    	ListFileHDD(fin);
    	return 0;
    }
    have no errors at all. Are you sure you include everything is needed?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I put this in the other thread, but those errors always occur in VC++ 2003 if you forget the #include <string>.

  3. #18
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Just for grins, what extension is your source file (.C or .CPP etc...) not that that's an issue here.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM