Hello,
I have started to write a program that uses structs, however I am unsure of how to get the data correctly into the array of structs. This is what I Have so far...
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct caneType Cane;
struct caneType{
char name[20];
int lattitude;
int longitude;
float force;
}hurricane;
int main (int agrc, char *argv[]){
char *str = *++argv;
FILE *fp, *fp2;
fp = fopen(str, "r");
fp2 = fopen(str, "r");
Cane storm[1000];
int i,input = 0;
do{
fscanf((fp2,"%s %i %i %f", &name, &lattitude, &longitude,&force) != EOF);
storm[i]=input;
i++;
}
while(i<1000);
return 0;
}
The input line will look like:
Code:
Alberto 80 8 42.720000
Im getting slightly confused on how to read this data from my input file and storing it into my array of structs.
Thanks for any suggestions...