Ah, according to wiki, "characters can be used as integers".
This may be the reason why the condition is not working as intended.
Nice find, but don't you mean the reason why it is
working? Actually, I assumed maybe we were getting confused about the discussion and which problem we were attributing it to. Let me clear up what I was talking about. Two things:
1) The OPs current problem. When she inputs something other than 'G' for the first prompt, she doesn't want the second prompt to display. This isn't really an error of any kind, her code is running fine. She just needs to add a condition to the second prompt to check for what input was given in the first prompt.
2) The fact that even though getchar() is an integer type, it still accepts character values. And when you use a condition which compares the integer value stored inside a char variable to an actual char value, it still works.
I believe you found the solution to 2) though. Characters can be passed as a type of int and thus the conditions using them work fine. I'm very certain that #2 has nothing to do #1 though, so declaring the variables c and d as characters instead of integers wouldn't effect the OPs current problem. It would however be good coding practice to declare them as int to keep a consistent variable type.
Edited by Vectris, 20 May 2010 - 11:30 AM.