title: Converting TCHAR to a char* for strstr function
body: <pre><code>    char skype[6] = "Skype";
      HWND firstwindow = FindWindowEx(NULL, NULL, NULL, NULL);
      HWND window = firstwindow;
      TCHAR windowtext[MAX_PATH]; //search term
  
      //We need to get the console title in case we
      //accidentally match the search word with it
      //instead of the intended target window.
      TCHAR consoletitle[MAX_PATH];
      GetConsoleTitle(consoletitle, MAX_PATH);
  
      while(true){
          //Check window title for a match
          GetWindowText(window, windowtext, MAX_PATH);
          if (strstr(windowtext, skype)!=NULL &amp;&amp; strcmp(windowtext, consoletitle)!=0) break; //search for program
              //Get next window
              window = FindWindowEx(NULL, window, NULL, NULL);
          if(window == NULL || window == firstwindow){
              printf("Window not found.\n");
              return 1;
          }
      } //end while
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Error: cannot convert 'TCHAR* {aka wchar_t*}' to 'const char*' for argument '1' to 'char* strstr(const char*, const char*)'
  </code></pre>
  
  <p>Problem occurs at this line:</p>
  
  <pre><code>if (strstr(windowtext, skype)!=NULL &amp;&amp; strcmp(windowtext, consoletitle)!=0) break; //search for program
  </code></pre>
  
  <p>I don't have a problem when I run the same program in cygwin mingw32gcc compiler. Is this a issue with me using QT mingw32gcc compiler? I have included <code>&lt;windows.h&gt;</code> at the very beginning so that's not the issue.</p>
  
  <p>Edit: Ok So I've added <code>&lt;tchar.h&gt;</code> and substituted
      if (_tcsstr(windowtext, skype)!=NULL &amp;&amp; _tcscmp(windowtext, consoletitle)!=0) break; </p>
  
  <p>But the problem still persists:  Error: cannot convert 'TCHAR* {aka wchar_t*}' to 'const char*' for argument '1' to 'char* strstr(const char*, const char*)'</p>