Hello. Last year I started learning C++. For this case, I used Microsoft Visual Studio Express. After the New Year holidays, I decided to continue learning the language (during this time I managed to reinstall the OS). Quickly I installed myself the g ++ compiler and the Geany IDE. To test the correct operation of my new tools, I decided to type a simple program.
# include & lt; iostream & gt ;;
#include & lt; cstdlib & gt ;;
#include & lt; windows.h & gt ;;
using namespace std;
int main ()
{
SetConsoleOutputCP (1251);
SetConsoleCP (1251);
cout & lt; & lt; "Hello world! \ N";
system ("pause");
return (0);
}
And on you, Cyrillic in the console is not displayed:
Everything worked in Visual Studio. What’s the problem?
Answer 1, authority 100%
Instead of editing, I clicked delete, sorry.
There are three options
- Doesn’t compile – SetConsole * MS
functions will not necessarily be
supported by another compiler. - If these functions are available in the library that comes with the compiler, do not
will definitely provide that
the same program behavior.
In general, these two options are valid for any non-standard functions.
- SetConsole * only affects
Unicode fonts, therefore it is necessary
set in console to display
just such a font (usually Lucida
Console)
Answer 2, authority 33%
As far as I understand, the SetConsoleOutputCP (1251) function works fine and translates the console to 1251 encoding, however the source code is saved in UTF-8.
Solution: select Windows-1251 encoding in a text editor (IDE settings).