working on a simple project

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.

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
  #include <iostream>

using namespace 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.
Topic archived. No new replies allowed.