Code:
if ( sex == m ) {
cout << "GO AWAY!!!" << endl;
}
else if ( sex == f ) {
cout << "Hey Baby ;).... call me!! " << endl;
You are trying to compare the input (sex) from the user for the characters m and f. A single character is represented in C/C++ by a single character surrounded by single quotes. Like so...
Code:
if ( sex == 'm' ) {
cout << "GO AWAY!!!" << endl;
}
else if ( sex == 'f' ) {
cout << "Hey Baby ;).... call me!! " << endl;
as Jessycat says since you have omitted the single quotes the compiler recognizes m and f as undeclared identifier literals. A common mistake is to confuse a character with a string and use double quotes to represent a character or single quotes for a string. Good programming practice would be to initialize each primitive variable when declared. Like so...
Code:
char sex = 'f'; // will change on user input
char str[100] = "\0"; //initializes each element of array of char with null terminator
string aStr = ""; // null string