How can I correctly handle special Portuguese characters like: ç, é, è and so on... using string in C?
I found how to do it with the printf but scanf, fgets and so on... I do not now how to properly storege on a string this kind of characters...
#include <locale.h>
int main (void){
setlocale(LC_ALL,"Portuguese");
printf("This is a example! Portuguese caracters ç é");
}
EDIT:
Tried this code as suggested bellow:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <wchar.h>
int main() {
int a = 0;
setlocale(LC_ALL,"Portuguese");
wprintf(L"Exemplo de ç\n");
return 0;
}
Compiling it from the console manually : gcc -o main.exe main.c works. But using devc++ gives me a error:
[Error] converting to execution character set: Invalid argument
If I put only: wprintf(L"Exemplo de\n"); (without the ç) devc++ now compiles well.
So once comliling it manually works I guess is something related with devc++ compile option... anyone know something about it?
EDIT2:
My main goal with all of this is to ask the user a input. read that input to save to a file. Everytime the program starts I will readu the file to restore the values saved on file.
But in Portuguese the user can type things such as ç, é, è ...