K
K
Konstantin Malyarov2016-04-19 10:40:42
C++ / C#
Konstantin Malyarov, 2016-04-19 10:40:42

How to fix the Visual Studio encoding so that there are Russian letters in the console?

#include <stdio.h>
#include <string.h>

int main() {
  char string1[] = "В зеленом горшочке.";
  char string2[] = "зел";
  int i = strstr(string1, string2);
  if (i != -1)
  {
    printf("Строка найдена. Ее адрес %i \n", i);
  }
}

The output is like this.
╤ЄЁюър эрщфхэр. ┼х рфЁхё 313523066

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Ananiev, 2016-04-19
@SaNNy32

setlocale(LC_ALL, "rus");

A
Alexander Taratin, 2016-04-19
@Taraflex

https://code-live.ru/post/cpp-cyrillic-manual/

I
I_dont_known, 2016-04-20
@I_dont_known

In the source code, in principle, you should not use any language other than English. For localization, use the appropriate libraries.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question