Hello. I am working on this simple code and I am having trouble with the
if statement to execute the "cout statement" below. Can anybody help me with this code.
#include <iostream>
usingnamespace std;
class People{
int popno;
char geograph1DNA[50];
public:
void Oldworld_distribution();
};
void People::Oldworld_distribution(){
cout<<"enter the population of western europe "<<endl;
cin>>popno;
cout<<"The population of Europe is "<<popno<<endl;
cout<<"Enter the genetic DNA of the area "<<endl;
cin.ignore();
cin.getline(geograph1DNA,50);
if(geograph1DNA=="Germanic"){
cout<<"the area is scandinavia "<<endl;
}
}
int main()
{
People group;
group.Oldworld_distribution();
return 0;
}
Line 20: You're trying to compare two char arrays with the == operator. That will only work if geograph1DNA is of type std::string. To compare two char arrays, you need to use the C library call strcmp.