I'm testing this function:
I'm entering characters from keyboard and I noticed that Ctrl-Z (EOF under windows) simply doesn't work, which I expected because of that line with ch == 0.Code:string ucitaj (int n) { string str; int i = 0; int ch; while ( ((ch = getch()) != EOF)) { if ((ch == 0) && (i > 0)) { getch(); i--; } if (isdigit(ch)) { cout<<static_cast < char > (ch); str += ch; i++; } if ( (ch == '\b') && (i > 0)) { cout<<"\b \b"; i--; } if ( i == n) { break; } } return str; }
My question is how to enable that loop quit after user press Ctrl-Z?
Thanks