Question about characters

So hi everyone ,i hope that you are doing well; this is just to test it's a part of the code that i have to write for my homework; i have a problem in the 2 last lines the program don't allow me to input Y or N it ends automatically
thank you

Last edited on
The %c format specifier can be used to read any kind of character, including whitespace characters. If you want to ignore leading whitespace characters you need to add a whitespace character in front of %c.

scanf(" %c",&r);
Last edited on
Thank you , i have an other problem
I want to do a calculation like for example for the item 1 its price multiplied by its quantity
ex: 15$*3
and i want to output each line differently(1 line = 1 item(and it's quantity)) then sum up the total
Hello Snow14

The only reason for the while loop to fail is if the condition becomes false as with a "y" as the entry. You should change the while condition to while (r == 'Y' || r == 'y') to catch either case. Untested for now, but it should work.

Hope that helps,

Andy
Topic archived. No new replies allowed.