Instead of asking me for the aperture value , the fprintf gets seemingly skipped , and the next thing that prints is that parture = 0.0f , when it hasnt even prompted me for an input :
Code:#include <stdio.h> int main(int argc, char * argv[]) { // Mainline Variable Declarations FILE * output = stdout; FILE * input = stdin; int exposure=0; float aperture=0; //Initiate the aperture variable - floating point number fprintf(output,"\nEnter Exposure Time: "); // Prompt the user for exposure time fscanf(input,"%5sd",&exposure); // Store exposure time in the exposure variable fprintf(output,"Please enter the aperture size - like so : f1.2\n"); // Prompt the user for the aperture size. fscanf(input,"f%f",&aperture); // Store the aperture value in the aperture variable. if ((aperture==1.2) || (aperture==1.4) || (aperture==1.8) || (aperture==2.0) || (aperture==2.8) || (aperture==4.0) || (aperture==5.4) || (aperture==8.0) || (aperture==11.0) || (aperture==16.0)|| (aperture==22.0) || (aperture==32.0)) { fprintf(output,"You have entered a defined aperture.\n"); fprintf(output,"::::::Values::::::Entered::::::\n\n"); fprintf(output,"The selected Exposure time is %d\n", exposure); // Print the exposure time entered on screen fprintf(output,"The selected Aperture is : f%.1f\n",aperture); // Print the aperture on screen } else { fprintf(output,"You have entered aperture value of f%.1f \n", aperture); fprintf(output,"This is an invalid aperture, the program will now exit\n"); return 0; } }



LinkBack URL
About LinkBacks


