Guys, I am a programming newbie so I need your help
I have written a program that generates a grid of 20 x20 random numbers. I need to insert 20 randomly distributed empty spaces into the grid.
My problem is, I have used the following array to insert the spaces but when I run the program I dont get the spaces. I get the number 32 in place of the spaces.
Code:
n = 20;
for (i = 0; i < n; i++)
{
array1[rand()%ROWS][rand()%COLS] = ' ';
}
for(r=0;r<ROWS;r++)
{
for(c=0;c<COLS;c++)
{
printf("%d", array1[r][c]);
}
printf("\n");
}
this is the bit of the code where spaces are meant to be generated
I know 32 is the ASCII code for the space character, but thats not what I want.How can I display the actual character in the grid rather than the code?
Thanks in advance guys, your help will be much appreciated.