I made this program to see how "ws" works
char character;
while (true){
character = cin.get();
cout << character;
if (cin.peek() == '\n') break;
cin >> ws;
}
cout << endl;
The program works with inputs (I use '_' to represent blank space) e.g: A___________________B__________C
Result: ABC
However, if I put a blank space at the end (like this: A_____________B__________C_), the program never ends and when debugging I find that the line (cin >> ws) never ends. My question is why is this happening.
Aucun commentaire:
Enregistrer un commentaire