[prog] C problem I am unable to solve

Dan dan at cellectivity.com
Thu May 12 05:29:42 EST 2005


Your problem may be here:

>         scanf("%c", &q);

See if it's reading the newline (Return or Enter) character as well as
the character you're looking for.

The man page for scanf says that "White space (such as blanks, tabs, or
newlines) in the format string match any amount of white space,
including none, in the input." So the solution may be as simple as
adding a newline or space to the end of the format string ("%c").

-- 
   Truth is incontrovertible: ignorance can deride it, panic may
   resent it, malice may destroy it, but there it is.
              - Winston Churchill




More information about the Programming mailing list