title: Compare function of string class not working as expected
body: <p>I want to search professors based on their names. So i have to compare the name i am entering to the professor name. I tried debugging, what's happening is that its not going into the if(compare) statement. And I can't figure out why. Its a quite big code so I'm just including a part of it. "professors" is a vector of type Professor which is class.</p>
  
  <pre><code>        void RecruitProfessor()
          {
              Professor prof = Professor();
  
              string college,name,role,subject;
              cout&lt;&lt;"Enter the College Name: ";
              fflush(stdin);
              getline(cin, college);
              cout&lt;&lt;"Enter the Professor Name: ";
              getline(cin, name);
              fflush(stdin);
              cout&lt;&lt;"Enter the Professor Role: ";
              getline(cin, role);
              fflush(stdin);
              cout&lt;&lt;"Enter the Professor Subject: ";
              getline(cin, subject);
              fflush(stdin);
  
  
              prof.setCollegeName(college);
              prof.setProfessorName(name);
              prof.setProfessorRole(role);
              prof.setProfessorSubject(subject);
              professors.push_back(prof);
          }
  
          void DisplayProfessorInfo()
          {
              bool returnToMainMenu = false;
              while(!returnToMainMenu)
              {
                  cout&lt;&lt;"1. Fetch the details of all the professors \n";
                  cout&lt;&lt;"2. Fetch the details of professors by Name \n";
                  cout&lt;&lt;"3. Fetch the details of professors by Role \n";
                  cout&lt;&lt;"4. Fetch the details of professors by Subject \n";
                  cout&lt;&lt;"5. Fetch the details of professors by Colleges \n";
                  cout&lt;&lt;"6. Return to main menu \n";
  
                  Professor prof = Professor();
                  int choice;
                  cout&lt;&lt;"Please enter your choice:\n";
                  choice = getInt();
                  switch(choice)
                  {
                      case 1:
                      {
                          if(professors.size()==0)
                          {
                              cout&lt;&lt;"\n\nNo professors found!\n\n";
                              returnToMainMenu = true;
                          }
                          else
                          {
                              for(Professor i:professors)
                              {
                                  //cout &lt;&lt; i.getProfessorCollege() &lt;&lt; endl;
                                  cout&lt;&lt;"Professor College: " + i.getProfessorCollege() + "\n";
                                  cout&lt;&lt;"Professor Name: " + i.getProfessorName() + "\n";
                                  cout&lt;&lt;"Professor Role: " + i.getProfessorRole() + "\n";
                                  cout&lt;&lt;"Professor Subject: " + i.getProfessorSubject() + "\n";
                                  cout&lt;&lt;"\n\n";
                              }
                          }
                          break;
                      }
                      case 2:
                      {
                          string name;
                          if(professors.size()==0)
                          {
                              cout&lt;&lt;"\n\nNo professors sfound!\n\n";
                              returnToMainMenu = true;
                          }
                          else
                          {
                              getline(cin, name);
                              fflush(stdin);
                              cin.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
                              //cout&lt;&lt;name;
                              for(Professor i:professors)
                              {
                                  if((name.compare(i.getProfessorName()))==0)
                                  {
                                      cout&lt;&lt;"Professor College: " + i.getProfessorCollege() + "\n";
                                      cout&lt;&lt;"Professor Name: " + i.getProfessorName() + "\n";
                                      cout&lt;&lt;"Professor Role: " + i.getProfessorRole() + "\n";
                                      cout&lt;&lt;"Professor Subject: " + i.getProfessorSubject() + "\n";
                                      cout&lt;&lt;"\n\n";
                                  }
                                  else{continue;}
                              }
                          }
                          break;
                      }
  </code></pre>