I need to read the following format of text:
text
textEOF
Where EOF is a single CTRL+D and the rest are just the characters (\n
is important).
The only way it does work is by adding another EOF after the first one, which I cannot do.
text
textEOFEOF
So I tried to use getchar(), but it seems to malfunction in some way or I am using it incorrectly. This is my code. What am I missing here?
string a;
int current;
do {
current = getchar();
if(current != EOF) a.push_back((char)current);
} while ( current != EOF );
cout << a;