title: C++ Strings Matching Returning False
body: <p>I'm working on my C++ assignment. I'm having an issue with string comparison.</p>
  
  <p>I'm comparing two apparently identical strings using == operating but the condition returns false. The debugger also shows that both strings (stored in different variables) are identical. I must be missing something.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void classCounter() {
  
      ifstream fread;
      string linetxt;
      char *records[50];
      char myLine[100];
      char delims[] = "|";
      int btotal=0,etotal=0,total=0;
  
      fread.open("F:\\myfile.txt");
  
      while(!fread.eof()) {
  
          getline(fread,linetxt,'\n');
  
          int i = 0;
          strcpy(myLine, linetxt.c_str());
          records[i] = strtok( myLine, delims );
  
          while( records[i] != NULL  ) 
          {
              cout &lt;&lt; records[i] &lt;&lt; "|";
  
              char *bu = "Business";
  
              if(records[i] == bu) {
                  btotal++;
  
              }
              if(records[i] == "Economy") {
                  etotal++;
  
              }
  
              //printf("%d '%s'\n", i, records[i]);
              records[++i] = strtok( NULL, delims );
              break;
          }
  
          total++;
      }
  
      cout &lt;&lt; "Total number of booked Business seats: " &lt;&lt; btotal &lt;&lt; endl;
      cout &lt;&lt; "Total number of booked Economy seats: " &lt;&lt; etotal &lt;&lt; endl;
  
      cout &lt;&lt; "Total number of booked seats: " &lt;&lt; total &lt;&lt; endl &lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>Here is what debugger shows:</p>
  
  <p><img src="https://i.stack.imgur.com/9YBpH.jpg" alt="enter image description here"></p>
  
  <p>Both if conditions are returning false.</p>
  
  <p>Please suggest what could be the issue.</p>