how would I print a 2d array in c using scanf for user input, array called grid[ ][ ] and a for loop?
say if the user types in 3 5, the output will be:
.....
.....
.....
Here is the code that I have written so far (newbie here):
#include <stdio.h>
#define MAX 10
int main()
{
int grid[MAX][MAX];
int row, col;
int i,j;
printf("Please enter your grid size: ");
scanf("%d %d", &row, &col);
for (i=0; i<MAX; i++)
for //i gave up here
}
This is only a little part of the whole stage of my task:
Enter number of rows and columns followed by list of words (hit enter twice to end list): 10 15
quick
brown
fox
jumped
over
lazy
dog
00 . . . . . . . . . . . . . . .
01 . . . . . . . . . . . . . . .
02 . . . . . . . . . . . . . . .
03 . . . . . . . . . . . . . . .
04 . . . . . . . . . . . . . . .
05 . . . . . . . . . . . . . . .
06 . . . . . . . . . . . . . . .
07 . . . . . . . . . . . . . . .
08 . . . . . . . . . . . . . . .
09 . . . . . . . . . . . . . . .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0. quick
1. brown
2. fox
3. jumped
4. over
5. lazy
6. dog
functions allowed and should be included in the code: string functions - strlen(),strcpy(), strcat(), strchr(), strcmp(),strstr()
must use 2d array
must use fgets for words. Out put must match the exact format.