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);
	if(another=='y'||another=='Y')
		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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.