Hi All,
I am having problems reading from a file into an array of structures.
I have defined an array of 100 structures as shown below.
struct address_t
{
char name[name_size];
int comp_one, comp_two, comp_three, comp_four ;
} ;struct address_t address[100];
I can fscanf into one structure no problems but cant work out how to scan into more than one. Here is the fscanf function that I am currently using-
fscanf(InFile,"%d.%d.%d.%d %s",&ap->comp_one, &ap->comp_two, &ap->comp_three, &ap->comp_four,&ap->name);
ap is the pointer to the structure.
I want to do something like this -
fscanf(InFile,"%d.%d.%d.%d %s",&ap->[i]comp_one, &ap->[i]comp_two, &ap->[i]comp_three, &ap->[i]comp_four,&ap->[i]name);
and use a for loop with the counter (i) do that I can scan to the next structure out of the 100 possible.
Any Ideas would be greatly appreciated,
Thanks for your time,
Paul.