I just wrote a random program using a data structure so I can experiment with some of the functions I had recently learned. But the one function that I don't fully understand is the cin.ignore() function. When do you think is the right time to include cin.ignore()?
The program below will ask you random questions, but in lines 47 and 48 seem to be a little bit buggy. When the structure variable is passed to function1, it counts the vowels in the char array but it doesn't count all of them.
For example: if the sentence has 3 vowels, the function will return 2 vowels.
Of course I know the problem is the "cin.ignore()" I placed in line 47. Once I removed it, the function returned the correct amount of vowels.
But my question is, why did cin.ignore() ignore the last vowel?
istream& ignore (streamsize n = 1, int delim = EOF);
Extract and discard characters
Extracts characters from the input sequence and discards them, until either n characters have been extracted, or one compares equal to delim.