ok I am making a maze for my school with gotoxy and getch and 2d character arrays I have 2 errors though when I am compiling it..

here's the source:

#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>

using namespace::std;


char moveR;
char moveL;
char moveU;
char moveD;
char move;
int mx=1;
int my=1;
int i, j;
char direction;
const char up_key='w', down_key='s', left_key='a', right_key='d';
char keypress;
char matrix[100][100];
void gotoxy(short x, short y)
{
      HANDLE hConsoleOutput;
      COORD Cursor_an_Pos = {x,y};
      hConsoleOutput = GetStdHandle (STD_OUTPUT_HANDLE);
      SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
}



void loadgrid()
{     
            for (i=0; i<26; i++)
      {
            for (j=0; j<42; j++)
            {
                  matrix[i][j]= {" ------------    ---------------------- \n","| | |____  |   | | |__ | ____    |     |\n","|  ____  |___| | | | __|_  | |____| _  |\n","| |____| |  _|_  |__     | | |  __|_ | |\n","|_|_           _____     | |_____   ___|\n","|     ___   |_   |  ________        |  |\n","|   |  |  ____   |       |  ___  |___  |\n","| | | _|      |  |    ___|  |  |     | |\n","|_| |___  |   |  | |_    |   __|__   | |\n","|  __  ___|   |______    |_______  |   |\n","|__| |___  ___   |___________| |_|_|_| |\n","|          |     |      _____|_      | |\n","| __  _____|_|___|                 | | |\n","| |     |    |  ___  |___   ___  |_|___ \n","| |   |_|_|  |  _______      |  _|_     \n","| | | | | |  |    |__________| |  _____|\n","| | |___|____| |  |  ___     __|_____| |\n","|_____  |      |     __________|  ___| |\n","|_____  |    |_|          _____|  |    |\n","|       |  | |    _|_             | |  |\n","|  | |___  |             _________| |__|\n","|  | |   | |    |    |_|_|         ____|\n","|  | |_____|    |_|_        |  | ____  |\n","|  |____|  ______   |___    |  |  _  | |\n","|     |    |            |   |  |   | | |\n"," ------------------------   ----------- \n"};
            }
      }
}



void printgrid()
{
      for (i=0; i<30; i++)
      {
            for (j=0; j<30; j++)
            {
                  printf("%c", matrix[i][j]);
            }
            printf("\n");
      }
}




int main()
{

loadgrid();
printgrid();

while (mx>0 && my>0)
{
      if (kbhit())
      {
            keypress=getch(); //keypress=(char)getchar()
            if ((keypress == right_key) || (keypress == left_key) ||
                  (keypress == up_key) || (keypress == down_key))
                  direction = keypress;
                  if (direction == 's')
                  {
                  gotoxy(mx,my);
                  printf(" ");
                  my=my+1;
                  gotoxy(mx,my);
                  printf("@");
                  gotoxy(mx,my);
                  }
                  if (direction == 'w')
                  {
                  gotoxy(mx,my);
                  printf(" ");
                  my=my-1;
                  gotoxy(mx,my);
                  printf("@");
                  gotoxy(mx,my);
                  }
                  if (direction == 'a')
                  {
                  gotoxy(mx,my);
                  printf(" ");
                  mx=mx-1;
                  gotoxy(mx,my);
                  printf("@");
                  gotoxy(mx,my);
                  }
                  if (direction == 'd')
                  {
                  gotoxy(mx,my);
                  printf(" ");
                  mx=mx+1;
                  gotoxy(mx,my);
                  printf("@");
                  gotoxy(mx,my);
                  }
                  direction = ' ';
      }
}






		system("COLOR 0B");	//Changes the background to black and forground to cyan.


		cout << "Directions: You are the symbol '@', When you want to move press 'w' to go up, 's' to go down, 'a' to go left, and 'd' to go right\n\n";
		cout << "NOTE: MAKE SURE ALL ENTERED LETTERS ARE LOWER CASE!!!!!!!";

		system("PAUSE");	//Pausing the screen before starting the program.


		system ("cls"); //Clears the screen


		//The start of the maze.

		//declaring the maze a giant array.


cout << "START OF THE MAZE!!!!!\n\n";

		//printing the maze array to the screen.

		//printing two extra lines after the maze is printed to the screen.
	cout <<endl <<endl;

			//pausing the screen before you go to the next step.
		system("PAUSE");

		//The end of the first part of the maze.

		system ("cls"); //Clears the screen


return 0;
}

I keep getting this error in it:

newmaze.cpp
newmaze.cpp(47) : error C2059: syntax error : '{'
newmaze.cpp(47) : error C2143: syntax error : missing ';' before '{'
newmaze.cpp(47) : error C2143: syntax error : missing ';' before '}'

no clue what it is talking about, could someone help me out?

matrix[i][j]= {" ------------    ---------------------- \n","| | |____  |   | | |__ | ____    |     |\n","|  ____  |___| | | | __|_  | |____| _  |\n","| |____| |  _|_  |__     | | |  __|_ | |\n","|_|_           _____     | |_____   ___|\n","|     ___   |_   |  ________        |  |\n","|   |  |  ____   |       |  ___  |___  |\n","| | | _|      |  |    ___|  |  |     | |\n","|_| |___  |   |  | |_    |   __|__   | |\n","|  __  ___|   |______    |_______  |   |\n","|__| |___  ___   |___________| |_|_|_| |\n","|          |     |      _____|_      | |\n","| __  _____|_|___|                 | | |\n","| |     |    |  ___  |___   ___  |_|___ \n","| |   |_|_|  |  _______      |  _|_     \n","| | | | | |  |    |__________| |  _____|\n","| | |___|____| |  |  ___     __|_____| |\n","|_____  |      |     __________|  ___| |\n","|_____  |    |_|          _____|  |    |\n","|       |  | |    _|_             | |  |\n","|  | |___  |             _________| |__|\n","|  | |   | |    |    |_|_|         ____|\n","|  | |_____|    |_|_        |  | ____  |\n","|  |____|  ______   |___    |  |  _  | |\n","|     |    |            |   |  |   | | |\n"," ------------------------   ----------- \n"};

That matrix can not be initialized like that -- you have to use strcpy() to copy all those strings into the array elements.

strcpy(matrix[0],"------------    ---------------------- \n");
strcpy(matrix[1],"| | |____  |   | | |__ | ____    |     |\n");
// etc. etc

or initialize the matrix on the same line where it was declared.

ok, Thanks

woo now it works =]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.