int main()
{
char c1, c2;
printf("Enter a character: ");
scanf("%c", &c1);
printf("Enter another character: ");
scanf("%c", &c2);

system("pause");
return;
}

Thats what my code looks like, the problem is the code skips the part where it lets you input c2. I dont understand why its doing this. It prints Enter another character: but doesnt take an input. any ideas?

Recommended Answers

All 2 Replies

Sure. See this and specifically this

I modified your code somewhat to display the intial/final values of c1/c2....What do you notice?

#include <stdio.h>

int main()
{
	char c1 = 0, c2 = 0;
	
	fprintf(stdout, "our initial values c1->%d, c2->%d\n", c1, c2);

	printf("Enter a character: ");
	scanf("%c", &c1);
	printf("Enter another character: ");
	scanf("%c", &c2);

	fprintf(stdout, "\nour final values c1->%d, c2->%d\n", c1, c2);

	return 0;
}
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.