With msvcrt.lib one can use printf and wprintf but with crt.lib one can only use one of them, the same goes for fprintf and fwprintf.
The one that is used depends on which one comes first in the listing.
#include <stdio.h>
#include <wchar.h>
int main(void)
{
char str[] = "Qwerty";
wchar_t wstr[] = L"Qwerty";
printf("char %s\n", str);
wprintf(L"wchar %ls\n", wstr);
return 0;
}
John
This is correct behaviour, as I understand it. Streams can in C99 be either byte-oriented or wide-oriented (they start with no orientation). Using a mix of orientation is undefined. When you use a byte-oriented function, like printf, the stream is set to byte-oriented. The function fwide can be used to set/check the orientation (can't change it, once it's set).
Pelle
Quote from: "Pelle"This is correct behaviour, as I understand it. Streams can in C99 be either byte-oriented or wide-oriented (they start with no orientation). Using a mix of orientation is undefined. When you use a byte-oriented function, like printf, the stream is set to byte-oriented. The function fwide can be used to set/check the orientation (can't change it, once it's set).
Pelle
Ok thanks, you are right.
Is this restriction new to C99 do you know?
John
Not sure. I don't have all the standard C documents available. The function fwide() was added in C99, and the whole issue became more "visible" at least...
Pelle
Quote from: "Pelle"Not sure. I don't have all the standard C documents available. The function fwide() was added in C99, and the whole issue became more "visible" at least...
Pelle
Ok thanks.
John