Simple question yet so hard 4 me

Guys,
I wrote these following statements in my program but the output is not as i expect.The compiler DID NOT ask any input for the * line.Why?

char a,d;

while (d!='n')
{
printf("B for Bus\n");
printf("C for Car\n");
printf("Vehicle type:");
scanf("%c",&a);
printf("ni ha:%c\n",a);
printf("Any more vehicle? [y/n]:");
*scanf("%c",d);
printf("po:%c",d);

}

Because there is an extra '\n' in the buffer. Use scanf(" %c"),&d); (notice the space before the %c)
may I suggest you to use cin and cout from the iostream library instead of scanf() and printf()? It's less confusing, imho, and sure more "C++ style" ^^'
Topic archived. No new replies allowed.