Hello,
I google and search through about the 2 dimension array and I still not really understand how to do it..
for example:
I got a file input called namelist.txt with following thing
John
Jason
Leonard
Kelly
Kate
Ash
and I got the following code:
#include <stdio.h>
int main ()
{
FILE* spopen;
char name[20];
int count = 0;
spopen = fopen ("list.txt", "r");
while ( (fscanf (spopen, "%s", &name)) != EOF)
{
printf ("%s\n", name);
}
return 0;
}
I got list of names print out, but how do I assign those names into array so that after that while loop, I can do the following thing.
for example,
let say I want to print the 2nd and 3rd name in the list (which is Jason and Leonard).
so I use,
printf ("%s \n %s \n", name[what to type?], name[What to type?]);
how do I assign all the names into array called nameAry? like:
nameAry[0][what to type?] = John
nameAry[1][what to type?]=Jason
nameAry[2][what to type?]=Leonard
nameAry[3][what to type?]=Kelly
nameAry[4][what to type?]=Kate
nameAry[5][what to type?]=Ash
Thank you in advance. and it is my 1st post here ^^.
Good day.