I'm trying to printf a character/String given by the user with accents, but this doesn't work.
After consulting a lot of forums, I think that <wchar.h> can solve my problem, but I have the same result.
main() {
setlocale(LC_ALL, "");
char buffer[50], choix;
printf("CHAR\nEntrez un char : ");
scanf(" %c", &choix);
printf("%c\n", choix);
getchar();
printf("Entrez votre éùàç prénom : ");
scanf("%s", buffer);
getchar();
printf("%s\n\n", buffer);
wchar_t wbuffer[50], wchoix;
printf("WCHAR\nEntrez un char : ");
wscanf(L" %lc", &wchoix);
wprintf(L"%lc\n", wchoix);
getchar();
wprintf(L"Entrez votre éùàç prénom : ");
wscanf(L"%ls", wbuffer);
getchar();
wprintf(L"%ls\n\n", wbuffer);
_getch();
}
The result was (on Windows 10 or Windows 11): result code
All of the 'literal printf' calls are working correctly, so what happened to the data from stdin? What am I missing?


