Witajcie, mam problem ze zliczaniem nowych linii, o to kod:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string tekst;
int i;
int licznik=0;
while(getline(cin, tekst))
{
if(tekst[i] == '\n')
{
licznik++;
}
cout << licznik;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Po kompilacji i wciśnięciu Enter program zamyka się z informacją, że przestał działać.