OK...I've had a go using the fscanf function as it would seem at first to be the easiest. However if I run the following program and specify a .dat file which is simply one line with "1 2". The program appears to do nothing. Is there something rather obvious I've done wrong here? Also, I've stopped almost ever using scanf in favour of gets, due to scanf's limitations - will the same problems arise with fscanf? Thanks,
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef struct number{
float no1,no2;
}NUMBER;
int main()
{
NUMBER number1;
FILE *fp;
char filename[256];
printf("\n\nEnter filename to read: ");
gets(filename);
fp = fopen(filename,"r");
fscanf(fp,"%f %f",number1.no1,number1.no2);
printf("%f\n%f",number1.no1,number1.no2);
}