My friend is having this problem :
Hi , Im having trouble with my code. Can you please look at it and show me ways of using fgets instead of fscanf as I get problems with it .
Code:
int main(int argc, char * argv[])
{
// Mainline Variable Declarations
FILE * output = stdout;
FILE * input = stdin;
int exp_time;
float aperture_value;
fprintf(output,"Please enter an exposure time: ");
fscanf(input,"%d",&exp_time);
fprintf(output, "Please Enter an Aperture Value: ");
fgets(aperture_value,10,stdin);
if
(aperture_value !=(1.2||1.4||1.8||2||2.8||4||5.6||8||11||16||22||32))
{
fprintf(output, "The value entered was incorrect. The accepted values are :\n f1.2, f1.4, f1.8, f2, f2.8, f4, f5.6, f8, f11, f16, f22, f32.\n\nProgram Closed.\n");
}
else{
(fprintf(output, "Aperture Value accepted."));
}
}
I tried using fgets as shown above in my code, but it didn't work . Thanks , much appreciated.