"Output" with special characters

4

I'm using the GCC version 5.3 compiler for the following program, written in Aptana:

#include <stdio.h>

void main(void)
{
    int positivo = 32767;
    int negativo = -32768;

    printf("%d +1 é %d\n", positivo, positivo+1);
    printf("%d -1 é %d\n", negativo, negativo-1); 
}

With the following output:

Alreadyinthetextblock,withthefollowing:

How do I make the characters appear correctly?

    
asked by anonymous 05.12.2016 / 23:51

1 answer

2

You probably need to use a setlocale() to allow the use of accented characters.

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

int main(void) {
    int positivo = 32767;
    int negativo = -32768;
    setlocale(LC_ALL,"Portuguese");
    printf("%d +1 é %d\n", positivo, positivo + 1);
    printf("%d -1 é %d\n", negativo, negativo - 1); 
}

See working on ideone and on CodingGround . But it's no advantage at all because they already worked without setlocale() . I had no way to test under your conditions to reproduce the problem.

    
06.12.2016 / 00:01