Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>_tmain is a macro that gets redefined depending on whether or not you compile with Unicode or ASCII. It is a Microsoft extension and isn't guaranteed to work on any other compilers.</p> <p>The correct declaration is</p> <pre><code> int _tmain(int argc, _TCHAR *argv[]) </code></pre> <p>If the macro UNICODE is defined, that expands to</p> <pre><code>int wmain(int argc, wchar_t *argv[]) </code></pre> <p>Otherwise it expands to </p> <pre><code>int main(int argc, char *argv[]) </code></pre> <p>Your definition goes for a bit of each, and (if you have UNICODE defined) will expand to </p> <pre><code> int wmain(int argc, char *argv[]) </code></pre> <p>which is just plain wrong.</p> <p>std::cout works with ASCII characters. You need std::wcout if you are using wide characters.</p> <p>try something like this</p> <pre><code>#include &lt;iostream&gt; #include &lt;tchar.h&gt; #if defined(UNICODE) #define _tcout std::wcout #else #define _tcout std::cout #endif int _tmain(int argc, _TCHAR *argv[]) { _tcout &lt;&lt; _T("There are ") &lt;&lt; argc &lt;&lt; _T(" arguments:") &lt;&lt; std::endl; // Loop through each argument and print its number and value for (int i=0; i&lt;argc; i++) _tcout &lt;&lt; i &lt;&lt; _T(" ") &lt;&lt; argv[i] &lt;&lt; std::endl; return 0; } </code></pre> <p>Or you could just decide in advance whether to use wide or narrow characters. :-)</p> <p><strong>Updated 12 Nov 2013:</strong></p> <p>Changed the traditional "TCHAR" to "_TCHAR" which seems to be the latest fashion. Both work fine.</p> <p><strong>End Update</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload