I was trying out a very simple calculator program:
Here's the code:

#include <stdio.h>
#include <stdlib.h>

// Calculator Program
// By 0xCMD

int main()
	double number1 = 0.0;	/* 	First operand value a decimal number 	*/
	double number2 = 0.0;	/* 	Second operand value a decimal number 	*/
	char operation = 0;		/* 	Operation - must be +, -, *, /, or % 	*/
	char another = 0;
calc_again:					/*	Label used by goto to start another calculation */
	printf("\nEnter the calculation\n");
	scanf("%lf %c %lf", &number1, &operation, &number2);

	/* Code to check the input */

	printf("Carry out another calculation ? (Y=yes, N=No): ");
	scanf(" %c", &another);
		goto calc_again;
    return 0;

In this line:

scanf(" %c", &another);

At the beggining of the string "
If i don't add a space after the begging and before the % character, the scanf() function is skipped, but If I add a space the function does not skip? Does anyone have any idea why?

7 Years
Discussion Span
Last Post by Dave Sinkula
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.