Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
You must be entering input in separate lines, like this string-input integer-input another-string-input Because, cin.getline() does not trim the whitespaces in the input, it stops accepting input when it encounters a newline. See here http://www.cplusplus.com/reference/istream/istream/getline/ "The delimiting character is the newline character ('\n') for the first form" So in your code, after the integer is accepted, a newline is encountered and input ends there. Try giving input like this (separated by space) string-input int-input another-string-input Or, you can pass in another argument to cin.getline(), that is a character that would be used as delimiter. So for example cin.getline(str, 50, '.') would stop accepting input when '.' is encountered or there is no input left
11th Mar 2021, 4:36 PM
XXX
XXX - avatar