В чем здесь проблема?

Пишу простую программу, которая работает с двумерным массивом 31*31. До этого написал аналогичную программу для одномерного массива. Там все прекрасно работало. Вот сам текст программы:

#include <iostream>
#include <cstdlib> // для system
#include <conio.h>
#include <stdio.h>
using namespace std;


int main()
{
    int ch;
    char wld[31][31];
    for (int i = 0; i < 31; i++) {
        for (int q = 0; q < 31; i++) {
            wld[i][q] = ' ';
        }
    }
    int posx = 15;
    int posy = 15;
    wld[15][15] = 'P';
    while (1 == 1) {
        ch = _getch();
        system("cls"); 
        if ((ch == 162) || (ch == 130)|| (ch == 68)|| (ch == 100)) {
            wld[posx][posy] = ' ';
            wld[posx + 1][posy] = 'P';
            posx++;
        }
         if ((ch == 228) || (ch == 148)|| (ch == 97)|| (ch == 65)) {
            wld[posx][posy] = ' ';
            wld[posx - 1][posy] = 'P';
            posx--;
        }
         if ((ch == 150) || (ch == 230) || (ch == 119) || (ch == 87)) {
             wld[posx][posy] = ' ';
             wld[posx][posy+1] = 'P';
             posy++;
         }
         if ((ch == 155) || (ch == 235) || (ch == 115) || (ch == 83)) {
             wld[posx][posy] = ' ';
             wld[posx][posy-1] = 'P';
             posy--;
         }
         for (int i = 0; i < 31; i++) {
             for (int q = 0; q < 31; i++) {
                 printf("%c",wld[i][q]);
             }
         }
         cout << endl;
    }
}

И собственно, что происходит. При попытке открыть программу, пишется, что программа вызвала исключение:

__declspec(noreturn) void __cdecl __raise_securityfailure(
    PEXCEPTION_POINTERS const exception_pointers
    )
{
    #ifdef _VCRT_BUILD
    DebuggerWasPresent = IsDebuggerPresent();
    _CRT_DEBUGGER_HOOK(_CRT_DEBUGGER_GSFAILURE);
    #endif // _VCRT_BUILD

    SetUnhandledExceptionFilter(NULL);
    UnhandledExceptionFilter(exception_pointers);

    #ifdef _VCRT_BUILD
    // If we make it back from Watson, then the user may have asked to debug
    // the app.  If we weren't under a debugger before invoking Watson,
    // re-signal the VS CRT debugger hook, so a newly attached debugger gets
    // a chance to break into the process.
    if (!DebuggerWasPresent)
    {
        _CRT_DEBUGGER_HOOK(_CRT_DEBUGGER_GSFAILURE);
    }
    #endif // _VCRT_BUILD

    TerminateProcess(GetCurrentProcess(), STATUS_SECURITY_CHECK_FAILURE);// тут исключение
}

Простите, если где ошибался. С таким сталкиваюсь впервые. Решил бы сам, но не понимаю смысла этого исключения. Для меня - это просто завершение программы.


Ответы (0 шт):