Hello! First time posting here. I've been learning C++ by myself for almost a week now and I'm currently learning about Variables, Input, Operations, Assignment and initialization.
#include "StdAfx.h"
#include "../std_lib_facilities.h"
int main()
{
string first_name;
string friend_name;
char friend_sex=0;
cout << "Enter the name of the person you want to write to: ";
cin >> first_name;
cout << "\n";
cout << "Dear " << first_name << ",""\n";
cout << " How are you? I'm doing fine. I'm really enjoying learning c++ it's great.""\n";
cout << "I hope you are doing fine, I also hope that you get this letter.""\n";
cout << "\n";
cout << "What is the name of another friend you have?: ";
cin >> friend_name;
cout << "\n";
cout << "Have you seen" << " " << friend_name << " " << "lately?""\n";
cout << "\n";
cout << "Enter 'm' if your friend is male, and 'f' if your friend is female: ";
cin >> friend_sex;
if (friend_sex='m')
cout << "If you see" << " " << friend_name << " " << "please ask him to call me.""\n";
else
cout << "If you see" << " " << friend_name << " " << "please ask her to call me.""\n";
keep_window_open();
return 0;
}
The part I am having trouble with is the if-statements.
1 2 3 4
if (friend_sex='m')
cout << "If you see" << " " << friend_name << " " << "please ask him to call me.""\n";
else
cout << "If you see" << " " << friend_name << " " << "please ask her to call me.""\n";
No matter whether I enter 'm' or 'f' it returns as if I entered 'm'.
It's probably a simple mistake, don't go too hard on me. :D