#include <stdio.h>
#include <stdlib.h>
//#define true 0
typedef struct
{
char currency[8];
int exchangerate;
} randT;
void main()
{
int i, num;
char currency1[8], ch;
FILE *file = fopen("address", "r");
randT name[7];
while(fscanf(file, "%i", &name[i].exchangerate) != EOF)/*I think this is where my problem is*/
{
fscanf(file, "%s %i", &name[i].currency, &name[i].exchangerate);
//printf("%s %i\n", currency1, num);
//if (fscanf(file, "%i", ¤cy1) == EOF) break;
printf("%s %i\n", name[i].currency, name[i].exchangerate);
i++;
}
fclose(file);
}
It is giving segmentation fault(core dumped) and i am fairly new to the fscanf functions and such. Please help! my text file looks like this: jeff 4 jina 5 jeffrey 6 jinna 7 jeffu 8 jinina 9 jeffz 10