Created
March 19, 2012 19:32
-
-
Save timpulver/2125363 to your computer and use it in GitHub Desktop.
Read a textfile line after line
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 <iostream> | |
#include <string> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
ifstream f; // Datei-Handle | |
string s; | |
f.open(argv[1], ios::in); // Öffne Datei aus Parameter | |
while (!f.eof()) // Solange noch Daten vorliegen | |
{ | |
getline(f, s); // Lese eine Zeile | |
cout << s << endl; // Zeige sie auf dem Bildschirm | |
} | |
f.close(); // Datei wieder schließen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment