Ezzel a megoldással több sort is lehet olvasni egy és megjeleníteni. A végén még az is kideül, hány sor van a fájlba....
Forráskód:
#include <iostream>
#include <fstream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
ifstream beolvas("vau.txt");
string temp;
int db=0;
while(!beolvas.eof()){
getline(beolvas,temp);
cout<<temp<<endl;
db++;
}
cout<<"Ennyi sor van "<<db-1<<endl;
beolvas.close();
return 0;
}
Videó: