Howto read only one line via c++ from a data
Posted
by
Markus Hupfauer
on Stack Overflow
See other posts from Stack Overflow
or by Markus Hupfauer
Published on 2012-06-21T14:38:57Z
Indexed on
2012/06/21
15:16 UTC
Read the original article
Hit count: 222
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
© Stack Overflow or respective owner