I created a function to validate the input of real numbers . It is working well , but as the atof()
function returns 0
upon failure, it is not possible to enter 0
as an input value. Anyone can give help to solve this?
float validate_float()
{
float num;
char str[8];
do
{
printf("enter a float number:");
fflush(stdin);
gets(str);
num=atof(str);
}
while(num==0);
return num;
}