When I ask the user to input their friends name, the output completely skips the option to enter any data.
Another issue is that when I select either m/f for male or female, my code doesn't implement the title= "Mr." or title = "Mrs." instead the output will just put m or f instead of Mr. or Mrs.
The main reason you shouldn't mix and match operator >> with getline is that operator >> leaves a newline in the buffer and getline reads until the newline. Before line 21 you need to add an ignore statement to ignore the newline left in the buffer. Something like
1 2 3 4 5 6 7
std::cin.ignore();
//or better
std::cin.ignore(1024, '\n');
//or even better
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
By the way shouldn't it be "Ms" and not "Mrs" or are assuming all the females are married?
Oh and the second problem is because you are outputting the gender and not title. The compiler doesn't know what you want it to do unless you tell it to do that.
after the input of a character in line 18, cin>>gender , the '\n' character is left in the buffer. It is this '\n' that is inputted in the getline .
you can fix this by using the standard function ignore() just after the input.
1 2 3
cin>>gender;
cin.ignore(); //ignore any data in the buffer.
About, the displaying 'm' and not "Mr", this is coz you used gender in your string literal instead of title .
So the reason why I couldn't use getline right after another is because the info stored in the first getline doesn't get overwritten so you have to use cin.ignore to completely nullify the memory of the first getline?
No, when you use std::cin >> variable; it leaves a newline in the buffer (from hitting enter). So before reading the buffer looks like 'm''\n' then after it looks like '\n' and std::getline(std::cin, variable); extracts until the delimiter is found (in this case the delimiter will be a newline - '\n') and then ignores the delimiter so in other words it extracts nothing and discards the newline since it is left in the buffer. You must ignore it first.