#include<iostream> using namespace std; int main(){ cout << "Привет"; system("PAUSE"); return 0; }
- This is such a hackneyed topic that Google has tons of links to this account. Check Control Panel -> Region and Language -> Administrative -> Change System Locale. [root @ host tmp] # cat> c.cpp #include <iostream> using namespace std; int main () {cout << "Hello" << endl; return 0; } [root @ host tmp] # g ++ c.cpp [root @ host tmp] # ./a.out Hello [root @ host tmp] # - void
- You have UTF-8 in the system, but it has a CP-1251. - deterok
- Has he indicated somewhere that he is using Windows? - void
- Yes, system ("PAUSE") ;. Win's a crutch (as far as I know). - deterok
- True, you can not argue. - void
|
2 answers
option 1
#include<iostream> #include <locale>// using namespace std; int main(){ setlocale(LC_ALL,"rus");// cout << "Привет"; system("PAUSE"); return 0; }
option 2
#include<iostream> #include <Windows.h>// using namespace std; int main(){ SetConsoleCP(1251);// SetConsoleOutputCP(1251);// cout << "Привет"; system("PAUSE"); return 0; }
option 3
#include<iostream> #include <Windows.h>//не помню какой из двух надо подрубить #include <locale>//и надо ли вообще using namespace std; int main(){ system("chcp 1251");// cout << "Привет"; system("PAUSE"); return 0; }
Also, in all toli, in some toli, you need to change the font in the console on Lucida Console
update
it all works on the text output in the code, only the 2nd works on the input and output from the console, it seems like it is the 2nd one (I did not check the 3rd one)
|
Try to save the source in utf-8. Should help.
- Strange advice. But the theme - Cyrillic in the console of Windows here periodically pops up. More often problems with cp1251 / cp866 encoding - alexlz
|