coding a 2D array rolling algorithm using WASD keyboard control

I want the program to initialize the 6x24 array with the pattern and display a static image on the console screen upon startup. And the six user control commands have to be ‘w’ for upward rotation, ‘s’ for downward rotation, ‘a’ for leftward rotation, ‘d’ for rightward rotation.

But when I run it, it doesn't work and shows me errors in line 11,22 and 34. And I'm having a feeling I'm doing this wrong.

CODE:

#include <stdio.h> // getchar(), getc(), fgets(), scanf()
#include <conio.h> // _kbhit(), _getch()
#include <unistd.h>
#define A_WIDTH 24
#define A_HEIGHT 6


int main()
{
int BigArray[6][24] =
{{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0};
{0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}};
}

char cmd = 0;

//program loop
while(cmd != 'x')
{

for(int i = 0; i < x_index; i++)
{
for(int j = 0; j < y_index; j++)
{

// this will NOT require ENTER key after the input to make it effective
if(_kbhit()) //if a keyboard hit is detected...
{
cmd = _getch();
printf("%d , BigArray[i][j], cmd);
}

}

}

}
Also here on your other thread.
https://www.cplusplus.com/forum/beginner/282316/
Stick to one thread please.
Topic archived. No new replies allowed.