0
#include <fstream>
#include <iostream>
using namespace std;
int main ()
{
fstream f;
char cstring[256];
f.open ("test.txt", ios::in);
short counter = 0;
while (!f.eof ())
{
f.getline (cstring, sizeof (cstring));
counter++;
cout << cstring << endl;
}
cout << "Anzahl der Zeilen:" <<counter << endl;
f.close ();
system ("PAUSE");
}
我想用std :: string替换Cstring,但f.getline不会将其作为参数。字符串而不是Cstring C++
完美,谢谢 – Etixpp 2014-11-02 21:39:18