[PS: this was sent to the wrong list]
john green wrote:
> the scanf seems to work. here is what i found
>
> see this is a simple c program
>
> ----------------------------------------
> #include<stdio.>
> main()
> {
> int p,q,area,perimter;
> scanf(%d",&p);
> scanf(%d",&q);
> printf("p=%d, q=%d", p,q);
> area = p*q;
> perimter = 2*(p+q);
> printf("area = %d",area);
> printf("perimter = %d", perimter);
> }
> ----------------------------------------------
> we have scanf twice so one would expect the program to take two inputs
> (from the keyboard in this case). but it wants three values. why does
> it need a third input. i am at a loss really.
> i input a no, <ENTER>, second no<ENTER>,third no and agian<ENTER> and
> then i get the output.
> WHAT is wrong and where ....
You should put a `\n' at the end of the printf() call.
stdout is line buffered by default. The buffer is only flushed when
either:
a) a newline is written to the stream
b) you call fflush() on the stream
c) some input is read from a stream which is associated with a TTY
device.
--
Glynn Clements <[EMAIL PROTECTED]>