title: Cannot compare strings in C++
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  FILE *pfile;
  using namespace std;
  
  string temp_string;
  string reserved[25] = {"AND", "CALL", "DECLARE", "DO", "ELSE", "ENDDECLARE", "ENDFUNCTION", "ENDIF", "ENDPROCEDURE", "ENDPROGRAM", "EXIT", "FALSE", "FOR", "FUNCTION", "IF", "IN", "INOUT", "NOT","OR", "PROCEDURE", "PROGRAM", "RETURN", "THEN", "TRUE", "WHILE"};
  
  
  int main(void)
  {
      pfile = fopen("hello.cel", "r");
      char cha, temp_token[30], temp;
      int count = 0, check = 1, i;
      cha = fgetc(pfile);
      while (cha != EOF)
      {
          if(isalpha(cha) || cha == '_')
          {
              temp_token[0] = cha;
              count = 1;
              cha = fgetc(pfile);
              while(isdigit(cha) || isalpha(cha) || cha == '_')
              {
                  if(count &lt; 30)
                  {
                      temp_token[count] = cha;
                      count++;
                  }
                  cha = fgetc(pfile);         
              }
              count--;
              for(i = 0; i &lt;= count; i++)
              {
                  temp_string += temp_token[i];
              }
              cout &lt;&lt; temp_string;
              for(i = 0; i &lt; 25; i++)
              {
                  if(temp_string == reserved[i])
                  {
                      printf(": RESERVED\n");
                  }
                  else
                  {
                      printf(": ALPHA\n");
                  }
              }
  
              cha = ungetc(cha, pfile);
              count = 0;
          }
          fclose(pfile);
  }
  </code></pre>
  
  <p>I have a problem with the comparison statement between the reserved[i] and temp_string strings. I cannot succeed printing "RESERVED", it always print "ALPHA".
  To your knowledge, this is a program that gets each character from a file (hello.cel) and prints the type of each token.</p>
  
  <p>EDIT: temp_token is a string were I temporary store words. This words have been made by adding characters at this line <code>temp_string += temp_token[i];</code></p>