title: String print out differently in Visual Studio and gcc
body: <p>I have created a simple project using Visual Studio 2012, and the code was compiled successfully, ran, and printed out as I expected (The fruit name is: apple). When I try to compile the same code with gcc, the print out looks different (The fruit name is: apple'). Where does the ' come from? Below is the code:</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt; 
  
  char * getCharValue(char line[]){
      char *pch = strchr(line, '='); //find where the equal sign is in the line
      char *pch1 = strchr(line, '\0'); // find the index of the end of the line
      char *info = (char *) malloc(sizeof(char) * (pch1-pch-4));
      info[pch1-pch-5] = '\0';
      // copy the value to a new array then return the new char;
      memcpy(info, &amp;line[pch-line+3], pch1-pch-5);
      return info;
  }
  
  int main()
  {   
      char nameFileName[] = "Name.txt";       //register file name;
      char *nameValue;
      FILE *fid = fopen(nameFileName, "r");
      if (fid != NULL){   
          char line[150];
          while(fgets(line, sizeof(line), fid) != NULL){   
              //if this line is not empty or a comment line
              if ((strncmp(line, "//", 2) != 0) &amp;&amp; (line[0] != '\n')) {   
                  if (strstr(line, "fruit_name") != NULL){
                      nameValue = getCharValue(line);
                      printf("The fruit name is: %s\n", nameValue);
                  }
              }
          }
      }
      else{
          printf("Can not find the input file.");
          exit(-1);
      }
      fclose(fid);
      return 0;
  }
  </code></pre>
  
  <p>The text file just contains 1 line as:</p>
  
  <pre><code>fruit_name           = 'apple'
  </code></pre>
  
  <p>Is there anything wrong with my code? How come it works with Visual Studio with no problem but cannot produce the right result using gcc?</p>