Compiled program can't display special characters

43 Views Asked by At

Currently I'm trying to display some portuguese characters in C++, in VS code terminal it displays fine but when I run the .exe file it displays abnormaly. Can someone please help me! Thanks in advance! :)

The code:

#include <iostream>
#include <locale.h>
using namespace std;

int add(int a, int b){
    return a + b;
}
int subtract(int a, int b){
    return a - b;
}
int multiplication(int a, int b){
    return a * b;
}
int division(int a, int b){
    return a / b;
}

main(){
    setlocale(LC_ALL, "Portuguese");
    float n1, n2;
    cout << "Número 1: ";
    cin >> n1;
    cout << "Número 2: ";
    cin >> n2;
    cout << "Soma: " << add(n1, n2) << "\n";
    cout << "Subtração: " << subtract(n1, n2) << "\n";
    cout << "Multiplicação: " << multiplication(n1, n2) << "\n";
    cout << "Divisão: " << division(n1, n2) << "\n";
}

In C++ btw.

I tried to import locale.h library and used the line setlocale(LC_ALL, "Portuguese"); inside of main(), I want to display special characters.

0

There are 0 best solutions below