well, you have to read line by line using a fgets function and use sscanf to get name and the number. the follwing code might help u
Code:
#include<stdio.h>
int main()
{
FILE *fp;
char name[25];
char buff[BUFSIZ];
float num;
if((fp=fopen("test.txt","r"))==NULL)
{
perror("File cannot be opened");
getchar();
exit(1);
}
while(fgets(buff,sizeof(buff),fp)!=NULL) // read a single line from the file till i get EOF
{
if(sscanf(buff,"%s %f",name,&num)==2) // getting the name and the number from the buffer which was read from the file
printf("%s %.1f\n",name,num);
else
printf("line cannot be printed\n");
}
getchar();
return 0;
}
/* myoutput
Sarah 111.2
John 222.3
Alan 333.4
*/
and the test file test.txt
Sarah 111.2
John 222.3
Alan 333.4
ssharish2005