I am learning C++ and facing an issue related to std::cout in C++. I am using vscode to program. Below is my code
int main(){
std::string sender_name;
std::cout<<"Enter the sender name: ";
std::getline(std::cin >> std::ws, sender_name);
std::string recipient_name;
std::cout<<"Enter the recipient name: ";
std::getline(std::cin >> std::ws, recipient_name);
int recipient_age=0;
std::cout<<"Enter the recipient_age of recipient: ";
std::cin>>recipient_age;
std::string friend_name;
std::cout<<"Enter your friend's name: ";
std::getline(std::cin >> std::ws, friend_name);
char friend_sex = 0;
std::cout<<"Enter 'm' for friend male and 'f' for the other: ";
std::cin>>friend_sex;
std::cout<<"Dear " + recipient_name+"," << std::endl;
std::cout<<std::endl;
std::cout<<"How are you? I am fine. I miss you."<<std::endl;
std::cout<<"Have you seen " +friend_name+" lately?"<<std::endl;
if (friend_sex == 'm'){
std::cout<<"if you see " + friend_name + " please ask him to call me."<<std::endl;
}
else if(friend_sex == 'f'){
std::cout<<"if you see " + friend_name + " please ask her to call me."<<std::endl;
}
else{
std::cout<<"if you see " + friend_name + " please ask him/her to call me."<<std::endl;
}
if(recipient_age <= 0 || recipient_age >= 110){
std::cout<<"you're kidding!"<<std::endl;
}
else{
std::cout<<"I heard that you just had a birthday and you are " + recipient_age;
std::cout<<" years old." << std::endl;
if(recipient_age < 12){
std::cout<<"Next year you will be " + (recipient_age+1);
std::cout<<"."<<std::endl;
}
if(recipient_age == 17)
std::cout<<"Next year you will be able to vote." << std::endl;
if(recipient_age > 70)
std::cout<<"I hope you are enjoying retirement."<<std::endl;
}
std::cout<<std::endl;
std::cout<<"Yours sincerely,"<<std::endl;
std::cout<<std::endl;
std::cout<<std::endl;
std::cout<<sender_name<<std::endl;
return 0;
}
And my output from terminal is missing some print statement
Enter the sender name: Sender
Enter the recipient name: Receiver
Enter the recipient_age of recipient: 30
Enter your friend's name: Neighbour
Enter 'm' for friend male and 'f' for the other: f
Dear Receiver,
How are you? I am fine. I miss you.
Have you seen Neighbour lately?
if you see Neighbour please ask her to call me.
rthday and you are years old.
Yours sincerely,
rthday and you are years old. should be I heard that you just had a birthday and you are 30 years old.
I thought there is no limit for cout to print. Can anyone give me some thought about this issue ?