Hello,
I am trying to read two floats from a file written in its first line using the below code but after compiling I always get "wrong dimnesions"
coulp please help me in that problem.
Thanks in advance.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
int main()
{
float width,height;
FILE *ifp;
char read[300];
ifp = fopen("thirdfile.txt","r");
if(ifp == NULL)
{
printf("failed to open file\n");
return 1;
}
if((fscanf(ifp, "%f %f ", &width,&height)) != 2)
{
printf("wrong dimmensions\n");
return 1;
}
if ( (width < 0.00) || (height < 0.00) || ( (fmod(width,1.00)) != 0.00) || ( (fmod(height,1.00)) != 0.00) )
{
printf("wrong dimmensions\n");
return 1;
}
fclose(ifp);
return 0;
}