Hello,
I am completely new to C programming so this may be a very trivial question but i cannot do it. I have to make a simple grid wich displays dots. The tricky part is that the user enters a width and a height and then the grid is generated and printed with that width and height. This grid needs to be stored in an array as well.
I believe im overcomplicating the problem but this is what i have so far:
Code:
# include <stdio.h>
int lx;
int ly;
char grid [10] [10];
int i;
int j;
int main()
{
printf ("Insert the width (Lx) and height (Ly) of the grid \n");
scanf ("%d %d", &lx, &ly);
for (i = 0; i < lx; i++)
{
for (j=0; j < ly; j++)
{
grid [i] [j] = ".";
}
}
for (i = 0; i < lx; i++)
{
for (j=0; j < ly; j++)
{
printf ("%c", grid [i] [j]);
}
}
}
The output that im getting is a line of i's rather than a grid. i need these to be dots in a 2d grid.... how do i go about this?
Thanks in advance.