i was wondering how do print a 2d array that would look like a square?
char theBoard[24][24]; //global variable
//code below is storing random char values in the in the array
//the output for this code would print all the values of the strings in single line
void random(char& random)
{
srand(1);
srand( time(0));
int i=rand()%7;
switch(i)
{
case 1:
random = '#';
break;
case 2:
random = 'o';
break;
case 3:
random = '!';
break;
case 4:
random = '+';
break;
case 5:
random = '~';
break ;
case 6:
random = '.';
break;
}
}
void draw()
{
char Random = ' ';
for(int i = 0;i<24;i++)
{
for(int j=0;j<24;j++)
{
random(Random);
theBoard[i][j]=Random;
cout<<theBoard[i][j];
}
}
}


Reply With Quote
