I have a problem when using printf
and wprintf
functions together in code. If the regular string is printed first, then wprintf
doesn't work. If I use wprintf
first then printf
doesn't work.
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL,"");
printf("No printing!\n");
wprintf(L"Printing!\n");
wprintf(L"Wide char\n");
printf("ASCII\n");
return 0;
}
Outputs:
No printing!
ASCII
While
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL,"");
wprintf(L"Printing!\n");
printf("No printing!\n");
wprintf(L"Wide char\n");
printf("ASCII\n");
return 0;
}
outputs:
Printing!
Wide char
I'm using gcc (GCC) 4.6.1 20110819 together with glibc 2.14 on 64bit Linux 3.0.