I have this code:
#include <stdio.h>
#define SIZE 100
int main(void) {
char myWord[SIZE];
printf("Enter \"blå\": ");
fgets(myWord, sizeof(myWord), stdin);
printf("Entered string: %s", myWord);
return 0;
}
And this is my output:
Enter "blå": blå
Entered string: bl
Why doesn't fgets
properly read the input? I changed the character encoding to UTF-8 using this guide:
Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)
This helped me print blå
instead of blå
but I still can't read input from the user. The only solution I can think of is that I need to change the encoding of stdin
. Do I do that with locale.h
or is there another way?
I am on windows and VScode and have MINGW32 as compiler.