Ok i decided to scrap the idea altogether but thank you for your help all of you. After scrapping the idea though i decided to do something else and now im having the same problem
Code:
char *NameArray[5] = {""};
float RateArray[5];
int j;
float Rate;
char Name[10];
clrscr();
ratesFile = fopen("rates.txt", "r");
if (ratesFile == NULL)
{
puts("Error opening file\n");
exit(0);
}
while ( fscanf ( ratesFile, "%f%s", &Rate, Name ) != EOF )
{
RateArray[i] = Rate;
NameArray[i] = Name;
printf("\n%s", Name);
printf("\n%s", NameArray[i]);
i++;
}
for (j=0; j<5; j++)
{
printf("\n%f", RateArray[j]);
printf("\n%s", NameArray[j]);
}
When i run this my output is as follows:
john
john
jack
jack
brian
brian
paul
paul
conor
conor
1
conor
2
conor
3
conor
4
conor
5
conor
does anyone know why the int value is being stored properly and why the string value is getting over written and only storing the last value once i exit the while loop????
Thank you all for the help last night