Hi,
Actually it is doing exactly what says.
When you enter a chracter, you actually enter 2 (a charcter and then
return). So when you tell scanf to get a character, whats left in the
stdin buffer is the return character.
See me addition below to get the effect you want.
John Gorman
On 23 Jun 98, at 20:56, James wrote:
> ok, compile this code, then explain why it does what it does...
>
> /* Start Of Code */
> #include <stdio.h>
>
> char c;
>
> int main ()
> {
> printf ("Scanf Test\n");
> printf ("enter a character >");
> scanf ("%c", &c);
fflush(stdin);
> printf ("Char was [%c]\n", c);
> printf ("Getc test\n");
> printf ("Enter a character >");
> c = getc (stdin);
> printf ("Char was [%c]\n", c);
>
> return 0;
> }
> /* End of Code */
>
> What does it do? It will let me input the first char, but never asks for
> the second. Why? and how can i make it ask for the second (or however many
> i ask it for).
>
> incidentally, i've seen EXACTLY the same 'feature' in Assembly, Pascal and
> Modula 2!
>
> -[[EMAIL PROTECTED]]--------------------------------------------
> ----- Http://x-map.home.ml.org Mailto :
> [EMAIL PROTECTED] ---[Quote Of The
> Day]---------------------------------------------------------- Old
> programmers never die. They just branch to a new address.
> --------------------------------------------------------------------------
> -----
>