Use accents in the Cout command

Asked

Viewed 871 times

0

Good afternoon. I know c++ uses another form of Asci, so there are no accents for example, so I come across problems like:

int main()
{
    cout << "é ó ê A ç";
}

Returns:

Ú ¾ Û A þ

Is there any way around this problem?

  • 3

    Search by locale. http://www.cplusplus.com/reference/clocale/

  • I found the solution, thank you

2 answers

1

#include <iostream>

using namespace std;

int main(){
    setlocale(LC_ALL, "pt_BR.UTF-8");
    cout << "Olá Mundo!" << endl;
}
  • Could give an explanation of how the code works and fit it in the AP example

  • Put an explanation of how the code works, because this answer will be read in the future by people of all degrees of knowledge and an explanation would facilitate the understanding of what is being done for beginners.

0


use this command here: setlocale(LC_ALL, "English");

if the function has not been declared, da include in the locale library

Browser other questions tagged

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