Created
November 12, 2012 16:51
-
-
Save paxswill/4060464 to your computer and use it in GitHub Desktop.
How to use getline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
int main(int argc, char** argv) { | |
ifstream inFile("data.txt"); | |
while(!inFile.eof()) { | |
string firstName, lastName, homeTown; | |
inFile >> firstName >> lastName; | |
getline(inFile, homeTown); | |
cout << firstName << " " << lastName << " from " << hometown; | |
} | |
inFile.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment