title: Comparing two char* for equality
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9122000/what-is-the-proper-function-for-comparing-two-c-style-strings">What is the proper function for comparing two C-style strings?</a>  </p>
  </blockquote>
  
  
  
  <p>My match condition doesn't work! Can someone advise how to compare to C-style strings?</p>
  
  <pre><code>void saveData(string line, char* data){
      char *testString = new char[800];
      char *stpr;
      int i=0;
      bool isData=false;
      char *com = data;
      strcpy(testString,line.c_str());
          stpr = strtok(testString, ",");
          while (stpr != NULL) {
              string temp = stpr;
              cout &lt;&lt; temp &lt;&lt; " ===== " &lt;&lt; data &lt;&lt; endl;
  </code></pre>
  
  <p>Even though <code>temp</code> and <code>data</code> match, the following condition doesn't work: </p>
  
  <pre><code>if (stpr==data) {
    isData = true; 
  }
  </code></pre>
  
  <p>Not sure if this helps. The <code>SaveData()</code> function is called from the function below:</p>
  
  <pre><code>void readFile(char* str){
      string c="", line, fileName="result.txt", data(str);
          ifstream inFile;
      inFile.open(fileName.c_str());
      resultlist.clear();
  
      if(inFile.good()){    
          while(!inFile.eof()){
              getline(inFile, line);
              if(line.find(data)!=string::npos){
                  cout &lt;&lt; line &lt;&lt; endl;
              }
              saveData(line, str);
          }
          inFile.close();
      }
  
  }
  </code></pre>