I have a problem with my code. I was writing a code to encrypt N number of sentences and when i enter the number of cases the program skip the next line (just like if i would have pressed "enter" twice)
cin>>N; the >> operator here will ignore leading whitespace. When it finds a non-whitespace character, it begins reading characters which form part of a valid integer. As soon as a non-numeric character is found, whether it be a space or a newline or maybe a letter of the alphabet, the extracting of characters stops.
Hence after that operation there will be at least a newline and possibly some other characters as well, remaining in the input buffer.
On the other hand, getline doesn't ignore whitespace. It reads characters from the input buffer until the delimiting newline is found, then it stops.
In order to remove the unwanted characters from the input buffer, do something like this:
1 2
cin>>N;
cin.ignore(100, '\n'); // ignore up to 100 characters, or until '\n' is found.