Hello, I've written a program where I ask for a name which I've given a list of name for and then I return their birthdate. I then ask the user if they would like to enter another name for a birthdate but this is where I can't figure out how to do it? When I run the code below it asks for a name, it displays their birthday - it asks if they want to enter another name and when I reply y - it starts the program again but doesn't let me enter another name it prompts the user if they wanna run the program again? I'm lost at this point.
since there might still be '\n' in the stream so getline kinda take that
because the last command before your getline is cin>>answer; which only take the char but not the enter ('\n') therefore the '\n' goes to the next input which is your getline and it takes it as if it's the input
why do you use get line anyway ?
You only want a single name without space