开发者

How do I read unicode and a number arguments from the command line in C for windows?

I have this code:

#include "stdafx.h"
#include <windows.h>
#include <开发者_如何学Python;conio.h>



int _tmain(int argc, _TCHAR* argv[])
{
    LPCTSTR f = argv[1];
    DWORD n = atoi(argv[2]);
    return 0;
}

I want to read a unicode string and a number. This is what I get after I compile:

error C2664: 'atoi' : cannot convert parameter 1 from '_TCHAR *' to 'const char *'


Instead of using atoi you need use _ttoi. This is because atoi accepts only ASCII strings where as you are trying to pass a UTF-16 string to it. BTW, do not include conio.h it is not a standard header file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜