Error flies

Run-Time Check Failure # 2 - Stack around the variable 'symbol' was corrupted.

In the code:

int main() { //system("chcp 1251"); setlocale(0, "Russian"); char symbol; cout << "Введите символ: "; cin >> symbol; OemToAnsi(&symbol, &symbol); cout << symbol; cout << endl; return 0; } 

The error appears only when I call the OemToAnsi (& symbol, & symbol); . In the process of tracing, I found out that the error crashes on the last command return 0; in main () .

How to fix it?

  • And you could not simplify the example to a minimum? - VladD
  • I just do not know why an error occurs. The error itself in return 0; in int main () {} - s1ash
  • Well, and you nevertheless make the minimum reproducing example. For example, if you remove CheckNameOfFile , then surely the problem will not disappear, and the code will become easier. - VladD
  • Reduced to a minimum, the error has changed - s1ash
  • Hm And what is the function of OemToAnsi ? What is her signature? Where is it defined? I can not find it in MSDN. - VladD

2 answers 2

 char symbol; cout << "Введите символ: "; cin >> symbol; OemToAnsi(&symbol, &symbol); 

I think she wants a normal string, not a character:

 char symbol[2] = {0, 0}; cout << "Введите символ: "; cin >> *symbol; OemToAnsi(symbol, symbol); 

    Solved a problem with

     OemToAnsiBuff(&symbol, &symbol, 1);