If statement wont seem to work

I am trying to get the user to enter an m for male or f for female and then store it into friend_sex then run that character through an if statement which will out output one of the two lines depending on the character entered. if anyone can tell me what i am doing wrong it would be greatly appreciated. thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
inline void keep_window_open() {char ch; cin >> ch; }

int main()
{
	cout << "Please enter the name of the person you want to write to:\n";
	string first_name;		// first_name is a variable of type string
	cin >> first_name;		// friend_name is a variable of type string
	cout << "What's the name of one of your best friends?:\n";
	string friend_name;		// friend_name is a variable of type string
	cin >> friend_name;		// read characters into friend_name
	char friend_sex = 0;
	char m, f;
	cout << "Enter an m if your friend is male and a f is your friend is female:\n";
	cin >> friend_sex;
	cout << "Dear " << first_name << ",\n";		// salutation of letter
	cout << endl;
	cout << "	How are you? I am fine. I miss you. When are you coming\n";
	cout << "back to visit me. We should get together and have some lunch or something.\n";
	cout << "Call me when you get back from vacation and we will work something out!\n";
	cout << "Have you seen " << friend_name << " lately?\n";
	
	if (friend_sex == m)
		cout << "If you see " << friend_name << " please ask him to call me.\n";
	if (friend_sex == f)
		cout << "If you see " << friend_name << " please ask her to call me.\n";
}
if (friend_sex == m) is comparing the car variable friend_sex to another char variable m. You should be saying:
if (friend_sex == 'm')
Alright it worked. thank you very much for your help.
Topic archived. No new replies allowed.