I'm coding a "sign finder", which lets you enter a sign (as an example a letter, an exclamation mark etc.) and then a sentence. After that it counts how many of those signs there are in the sentence. From the beginning it only counted how many a:s there were in a sentence, and that worked perfectly. But as soon as I wanted to make the program "universal" or whatever, it stopped working. This is what it outputs:
What sign do you want to test? B
Enter a sentence in English: You did not enter a proper sentence!
It is kind of right, I did not enter a proper sentence, but that was because it didn't even let me do it -.- Does anyone know how to fix this irritating error?
After this cin >> sign; there is a newline character '\n' remaining in the input buffer. The next getline() will pick up everything until the newline which is of course an empty string.
Get rid of the unwanted newline by adding cin.ignore(); after the cin >>sign;