If I want to read to a buffer a specified number of characters I'll use:
But if the user writes more than 11 characters I'm in trouble when I want to read next time:Code:char text[12]; ... cin >> setw(sizeof(text) / sizeof(char)) >> text;
I'm gessing that the characters the user put in that the first cin ignored still is in the istream-buffer, but I don't know how to clear the istream-buffer.Code:int i = 0; ... cin >> i;
I tryed to use also:
but it works only worse.Code:cin.getline(text, 12);
Any suggestions?
Suzi




Reply With Quote