I can now validate whether a number is a valid float number or not but i'm having problems in getting the values from a text file. Can someone help me?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int check_floatnum(double *output)
{
double floatnum;
FILE *fp1;
char *end, fnum[32];
if(fgets(fnum, sizeof(fnum), stdin) && !isspace(*fnum) && (*output = strtod(fnum, &end)), ( *end == '\n' || *end == '\0' ))
printf("VALID\n ");
else
printf("INVALID\n ");
}
int main(void)
{
double floatnum = -12.3;
do
{
fp1 = fopen("C:\\input.txt","r");
}
while (check_floatnum(fp1));
fclose(fp1);
}