title: _stricmp returns wrong value while string DOES match. What to do?
body: <p>I have this bit of code:</p>
  
  <pre><code>                        second = strtok (NULL,"\n");
                          logprintf(second);
                          if(_stricmp(second,"WINDOWS") == 0)
  </code></pre>
  
  <p>The logprintf prints data into a logfile, and it prints "WINDOWS" (without quotes).</p>
  
  <p>but _stricmp returns 13 somehow.. So the if check never gets passed. I've tried doing sscanf/sprintf/other string ways but none work. I'm out of ideas.</p>
  
  <p>The full code:</p>
  
  <pre><code>#ifdef WIN32
  
  
  char buf[65535];
  bool found = false;
  bool install = false;
  bool installing = false;
  unsigned int installed = 0;
  
  
  WIN32_FIND_DATA fd;
  HANDLE h = FindFirstFile(L"./*.AIFPAK", &amp;fd);
  
  char * NAME = NULL;
  char * ID = NULL;
  char * AUTHOR = NULL;
  int VERSION;
  
  HZIP hz = OpenZip(fd.cFileName,0);
  
  ZIPENTRY ze; 
  GetZipItem(hz,-1,&amp;ze); 
  int numitems=ze.index;
  for (int i=0; i&lt;numitems; ++i)
  { 
      GetZipItem(hz,i,&amp;ze);
  
      if(found == false)
      {
          if(_wcsicmp(ze.name,L"INSTALL.AIFLIST") == 0)
          {
              found = true;
              UnzipItem(hz,i,buf,65535);
              i = 0;
              stringstream strx;
              strx &lt;&lt; buf;
              string line;     
              while (getline(strx, line)) { 
                  char * first = NULL;
                  char * second = NULL;
                  char * third = NULL;
                  first = strtok ((char *)line.c_str()," ");
                  if(install == false)
                  {
                      if(_stricmp(first,"NAME") == 0)
                      {
                          NAME = strtok (NULL,"\n");
                      }
                      if(_stricmp(first,"ID") == 0)
                      {
                          ID = strtok (NULL,"\n");
                      }
                      if(_stricmp(first,"AUTHOR") == 0)
                      {
                          AUTHOR = strtok (NULL,"\n");
                      }
                      if(_stricmp(first,"VERSION") == 0)
                      {
                          VERSION = atoi(strtok (NULL,"\n"));
                      }
                      if(_stricmp(first,"START_INSTALL") == 0)
                      {
                          second = strtok (NULL,"\n");
                          logprintf(second);
                          if(_stricmp(second,"WINDOWS") == 0)
                          {
                              cout &lt;&lt; "INSTALLAH\n";
                              install = true;
                              cout &lt;&lt; NAME &lt;&lt; "|" &lt;&lt; ID &lt;&lt; "|" &lt;&lt; AUTHOR &lt;&lt; "|" &lt;&lt; VERSION &lt;&lt; "|\n";
                          }
                      }
                  }
                  else
                  {
                      cout &lt;&lt; "ELSE FIRST: " &lt;&lt; first &lt;&lt; "\n";
                      if(_stricmp(first,"UNPACK") == 0)
                      {
                          second = strtok (NULL,"&gt;");
                          third = strtok (NULL,"\n");
                          cout &lt;&lt; first &lt;&lt; "|" &lt;&lt; second &lt;&lt; "|" &lt;&lt; third &lt;&lt; "|\n";
                          ToDoVec.push_back(ToDoInfo(0,second,third));
                      }
                      if(_stricmp(first,"PRINT") == 0)
                      {
                          second = strtok (NULL,"\n");
                          cout &lt;&lt; first &lt;&lt; "|" &lt;&lt; second &lt;&lt; "|" &lt;&lt; third &lt;&lt; "|\n";
                          ToDoVec.push_back(ToDoInfo(3,second,""));
                      }
                      if(_stricmp(first,"ADD_PLUGIN") == 0)
                      {
                          second = strtok (NULL,"\n");
                          cout &lt;&lt; first &lt;&lt; "|" &lt;&lt; second &lt;&lt; "|" &lt;&lt; third &lt;&lt; "|\n";
                          ToDoVec.push_back(ToDoInfo(1,second,""));
                      }
                      if(_stricmp(first,"ADD_FILTERSCRIPT") == 0)
                      {
                          second = strtok (NULL,"\n");
                          cout &lt;&lt; first &lt;&lt; "|" &lt;&lt; second &lt;&lt; "|" &lt;&lt; third &lt;&lt; "|\n";
                          ToDoVec.push_back(ToDoInfo(2,second,""));
                      }
                      if(_stricmp(first,"END_INSTALL") == 0)
                      {
                          break;
                      }
                  }
              } 
          }
      }
      else
      {
          if(installing == false)
          {
              i = 0;
              installing = true;
              for(unsigned int ix = 0; ix &lt; ToDoVec.size(); ++ix)
              {
                  cout &lt;&lt; "|" &lt;&lt; ToDoVec.at(ix).action &lt;&lt; "|" &lt;&lt; ToDoVec.at(ix).string1 &lt;&lt; "|" &lt;&lt; ToDoVec.at(ix).string2 &lt;&lt; "|\n";
              }
          }
          else
          {
  
          }
      }
  }
  found = false;
  install = false;
  installing = false
  CloseZip(hz);
  
  while (FindNextFile(h, &amp;fd))
  {
  //fnVec.push_back(fd.cFileName);
  }
  #else//assuming linux
  
  #endif
  </code></pre>
  
  <p>The "INSTALL.AIFLIST" file looks like this:</p>
  
  <pre><code>NAME Route Connector Plugin
  ID GAMER_GPS
  VERSION 1733
  AUTHOR Gamer_Z
  
  START_INSTALL WINDOWS
  
  UNPACK RouteConnector/plugins/RouteConnectorPlugin.dll&gt;./plugins/RouteConnectorPlugin.dll
  UNPACK RouteConnector/examples/other/filterscripts/Node_GPS.amx&gt;./filterscripts/Node_GPS.amx
  UNPACK RouteConnector/examples/other/filterscripts/Node_GPS.pwn&gt;./filterscripts/Node_GPS.pwn
  UNPACK RouteConnector/scriptfiles/GPS.dat&gt;./scriptfiles/GPS.dat
  UNPACK RouteConnector/sampGDK/EXTRACTED/libsampgdk-2.2.1-win32/bin/sampgdk2.dll&gt;./sampgdk2.dll
  
  ADD_PLUGIN RouteConnectorPlugin
  ADD_FILTERSCRIPT Node_GPS
  
  END_INSTALL
  
  START_INSTALL LINUX
  
  UNPACK RouteConnector/plugins/RouteConnectorPlugin.so&gt;./plugins/RouteConnectorPlugin.so
  UNPACK RouteConnector/examples/other/filterscripts/Node_GPS.amx&gt;./filterscripts/Node_GPS.amx
  UNPACK RouteConnector/examples/other/filterscripts/Node_GPS.pwn&gt;./filterscripts/Node_GPS.pwn
  UNPACK RouteConnector/scriptfiles/GPS.dat&gt;./scriptfiles/GPS.dat
  PRINT To make this plugin work you must install the sampgdk library from www.github.com/Zeex/ (if you don't have it installed)
  
  ADD_PLUGIN RouteConnectorPlugin.so
  ADD_FILTERSCRIPT Node_GPS
  
  END_INSTALL
  </code></pre>
  
  <p>All the data is read correctly into 'buf'.</p>
  
  <p>Can anybody suggest how to fix that problem?</p>