Reading a special character like char using locale does not work. How to fix it?

Asked

Viewed 63 times

2

I’ll give a very simple example to explain my doubt:

#include <stdio.h>
#include <conio.h>
#include <locale.h>

main(){

    setlocale(LC_ALL,"Portuguese");
    char a;

    printf("Insira um caractere especial,\nExemplos: ç, á, é, ê, ã, à...\n>>");
    scanf("%c", &a);

    printf("Você digitou '%c'", a);

    getch();

    return 0;
}                         

It does not consider the locale when reading the user character, would like to learn how to fix it! I have been told that it is necessary to change the character encoding from DEV C++ to UTF-8, does this information proceed? Because I haven’t found how to do this...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.