Hi guys,
i m have trouble with reading strrings and storing them in a 2d array and printing them
(1)[CODE=c]for(y=0;y<5;y++ )
{
printf("enter filenames \n");
scanf("%s",&fna mes[y][0]);
}
for(y=0;y<5;y++ )
{
printf("filenam e %s\n",&fnames[y][0]);
}
(2) for(y=0;y<5;y++ )
{
printf("enter filenames \n");
scanf("%s",fnam es[y]);
}
for(y=0;y<5;y++ )
{
printf("filenam e %s\n",fnames[y]);
}
[/CODE]
for both the programs if the input were to be:
aaa
bbb
ccc
ddd
eee
the output is
aaabbb......eee
bbb.....eee
cc...eee
d...eee
eee
what could be wrong?
i thought fname[y] refers to the base address of yth 1D array in the 2D array.
i m have trouble with reading strrings and storing them in a 2d array and printing them
(1)[CODE=c]for(y=0;y<5;y++ )
{
printf("enter filenames \n");
scanf("%s",&fna mes[y][0]);
}
for(y=0;y<5;y++ )
{
printf("filenam e %s\n",&fnames[y][0]);
}
(2) for(y=0;y<5;y++ )
{
printf("enter filenames \n");
scanf("%s",fnam es[y]);
}
for(y=0;y<5;y++ )
{
printf("filenam e %s\n",fnames[y]);
}
[/CODE]
for both the programs if the input were to be:
aaa
bbb
ccc
ddd
eee
the output is
aaabbb......eee
bbb.....eee
cc...eee
d...eee
eee
what could be wrong?
i thought fname[y] refers to the base address of yth 1D array in the 2D array.
Comment