M
madhura
Hello,
I have a problem with 2-d arrays and scanf function.
I have wriitten a code in which i am accepting values in 1-d arrays
int a[5],i;
for(i=0;i<3;i++)
scanf("%d",a+i);
when I print the values, it showed me the correct values,but when i
wrote the same code for 2-d arrays,
int a[2][2],i,j;
for(i=0;i<2;i++)
for(j=0;j<2;j++)
scanf("%d",a+i+j);
after printing,it showed me garbage values for a[0][1] and a[1][1], is
it because my compiler doesnt have the program for handling such
expressions.
why this happened, can anybody tell me,
cheers
madhura
I have a problem with 2-d arrays and scanf function.
I have wriitten a code in which i am accepting values in 1-d arrays
int a[5],i;
for(i=0;i<3;i++)
scanf("%d",a+i);
when I print the values, it showed me the correct values,but when i
wrote the same code for 2-d arrays,
int a[2][2],i,j;
for(i=0;i<2;i++)
for(j=0;j<2;j++)
scanf("%d",a+i+j);
after printing,it showed me garbage values for a[0][1] and a[1][1], is
it because my compiler doesnt have the program for handling such
expressions.
why this happened, can anybody tell me,
cheers
madhura