K
K
kpa6uu2015-11-11 19:50:15
Programming
kpa6uu, 2015-11-11 19:50:15

Why is the Cyrillic alphabet crooked in VC++?

Hello.
The problem is that the Cyrillic alphabet is crooked.
For example:

#include <iostream>
#include <string>
#include <locale.h>

using namespace std;

class employee{
private:
  string name;
  long number;
public:
  void getdata();
  void putdata();
};

int main(){
  setlocale(LC_ALL, "Russian");
  employee em1, em2;
  em1.getdata();
  em2.getdata();
  em1.putdata();
  em2.putdata();
  system("pause");
  return 0;
}

void employee::getdata(){
  cout << "Введите имя: "; cin >> name;
  cout << "Введите номер: "; cin >> number;
}

void employee::putdata(){
  cout << name   << endl
     << number << endl;
}

52f3b69e84e3487c998f253b4ff45ce2.png

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Dmitry, 2015-11-14
@kpa6uu

We use SetConsoleOutputCP and there will be happiness.

V
Vitaly Vitrenko, 2015-11-11
@Vestail

Due to the fact that cmd has an old encoding. The best solution is to use only English. You won't be using console projects anyway.

S
Saboteur, 2015-11-11
@saboteur_kiev

Fix console, set console to normal fonts. Use conemu as default console.
The problem is with the encoding.

V
vvafree, 2016-08-02
@vvafree

setlocale(0, "");

R
roodz, 2018-05-26
@roodz

#if defined(_WIN32) || defined (_WIN64)
    #include <windows.h>
    #define OS_WIN 1
#endif

int main()
{
    #ifdef OS_WIN
        SetConsoleOutputCP(1251);
        SetConsoleCP(1251);
    #else
        setlocale(LC_CTYPE, "Russian");
    #endif

    // ...

    return 0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question