I want to make text file, filling him string by string, until empty string. But, somehow I have infinite input, what conidition need I make to escape infinite loop?
Here is my code:
fstream f;
f.open("text1.txt", ios::out);
bool flag = false;
while (!flag) {
char buf[50];
cin >> buf;
if (strlen(buf)!=0 )
f<<buf<<endl;
else {
f.close();
flag = true;
}
}