I have an assignment to program a simple program that names each member in my family and how they are related to me. The program compiles and all, but as soon as i type in any name, this is what shows up:
Run Command: line 1: 3805 Segmentation fault: 11 ./"$2"
my code is as follows:
#include <iostream>
#include <string>
using namespace std;
int main()
{
char genderType;
char* name;
cout<<"Enter M if you are a male. Enter F if you are a female: ";
cin>>genderType;
if (genderType == 'm' || genderType=='M')
{
cout<<"You are a male."<<endl;
cout<<"Please type in your first name in all lowercase letters: ";
cin>>name;
if (name=="hussein")
cout<<"You are my eldest brother! ";
else if (name=="ahmed")
cout<<"You are my older brother! ";
else (name =="kamal");
cout<<"You are my father! ";
}
else if (genderType=='f' || genderType=='F')
{
cout<<"You are a female."<<endl;
cout<<"Please type in your first name in all lowercase letters: ";
cin>>name;
if (name=="hinda")
cout<<"You are my eldest sister! ";
else if (name=="iman")
cout<<"You are my older sister! ";
else (name=="ikhlas");
cout<<"You are my mother! ";
}
else
{
cout<<"Sorry, you can only be a male or female! ";
}
}