Im trying to make a basic C console application calculator. Yet when i execute it the second scanf command is skipped and the third is run instead. This is a problem as here i need to get operation of the user +, -, *, or /. How do i stop this from happening?
float num1;
char sign;
float num2;
float total;
printf("~~~ Calculator ~~~\n");
printf("Please enter the first number: ");
scanf("%f", &num1);//Get value of num1 from user
printf("\nNow please enter the operation , either +, -, *, or / : ");
scanf("%c", &sign);//Get value of sign from user
printf("\n\nFinaly enter the second number: ");
scanf("%f", &num2);
Edit: Actually after trying various suggestions it seams a space before the %c was the correct way and cleanest way of fixing things. Thanks for the help.