Thread: getline I/O

  1. #1
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65

    getline I/O

    This should be a fairly simple question, but how do I get a whole line from a file and store it as a string?

    This is what I have right now:
    Code:
    int main()
    {
    	string a = "";
    	string b = "";
    	string fileName = "";
    
    	cout << "Enter file name (case sensative): ";
    	cin.ignore();
    	cin >> fileName;
    /////////////////////////////////////////////////////////////////////////
    //	Input File
    /////////////////////////////////////////////////////////////////////////
    	
    	try {
    	ifstream b_file(fileName.c_str());
    	b_file >> a;
    	b_file.close();
    
    //more stuff...
    }
    All it spits out is the first word though.
    Last edited by Azmeos; 07-08-2003 at 11:15 AM.
    \0

  2. #2
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    Nevermind, I seem to answer a lot of my own questions...
    \0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  2. problem with getline() file I/O
    By hyperion in forum C++ Programming
    Replies: 4
    Last Post: 12-08-2003, 09:34 AM
  3. getline() and file I/O
    By 7stud in forum C++ Programming
    Replies: 12
    Last Post: 05-01-2003, 01:49 PM
  4. getline i/o
    By kylesbigdog in forum C++ Programming
    Replies: 8
    Last Post: 04-23-2003, 08:25 AM
  5. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM