In a project i need to set “use unicode character set” for Configuration Properties>General>Character Set.
On compiling the project, error c2664 is returned on this code:
char Filename[25] = {0};
GetLocalTime(&st);
sprintf(Filename,TEXT("C:\\CpmMicr%02d%02d%04d.log"), st.wDay,st.wMonth,st.wYear);
When I change the character set configuration to “Not set” or “Multi-byte character set”
project compiles without any errors.
Please suggest me on what should be done to fix this issue.
Thanks for any potential suggestions.
Lakshmi.
It is because you use the TEXT macro. That automatically puts an L before a string literal if you compile with _UNICODE defined. That blows up because you use sprintf(), a non-Unicode function. It wants a char*, not a wchar_t*.
There are three basic solutions here:
No real point in 2, there is no mainstream operating system left that isn’t native Unicode.