Howto read only one line via c++ from a data
- by Markus Hupfauer
i tryed to read the first line of a .dat data, but when i tryed to give to text, wich was saved in the .dat data, it print out the whole data, not only one line. the tool is also not looking after breaks or spaces :(
Im using the following code:
//Vocabel.dat wird eingelesen
ifstream f; // Datei-Handle
string s;
f.open("Vocabeln.dat", ios::in); // Öffne Datei aus Parameter
while (!f.eof()) // Solange noch Daten vorliegen
{
getline(f, s); // Lese eine Zeile
cout << s;
}
f.close(); // Datei wieder schließen
getchar();
.
So could u help me please ?
.
Thanks a lot
Markus