开发者

How to open a file using _TCHAR* as a file name? c/c++

My main has the following signature:

int _tm开发者_如何学JAVAain(int argc, _TCHAR* argv[])

I would like to preform the following:

FILE *inputFilePtr;
inputFilePtr = fopen(argv[2], "_r");

But there is a type mismatch. How should I do it? Should I use:

inputFilePtr = _tfopen(argv[2], ??????);

Thanks!


Use:

_tfopen(argv[2], TEXT("r")); 

Do not use:

_tfopen(argv[2], L"r");

The second one will give compilation error if the macro UNICODE is not defined, that is, when TCHAR is just char, not wchar_t.


Use _tfopen(argv[2], TEXT("r"));

or _tfopen(argv[2], L"r"); if TCHAR is WCHAR.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜