|
From: Daniel K. O. <dan...@ya...> - 2002-08-07 23:34:32
|
Carlos García del Monte wrote:
>
> scanf("%d\n", &tall);
> printf("and then choose the weight\n");//THESE TWO LINES CHANGE THE
ORDERING!!!!!
> scanf("%d\n", &weight);
The control string in a scanf() call can be one of these 3 types:
- format specifier
- white space
- non white space
When you use a control string like "%d,%d", scanf will read an int, read and
discard a comma, and read another int.
Same happens with your "%d\n" control string; it will read an int, then read
and discard a new-line caracter.
When scanf() can't find the non white space caracter, it normally finish,
and some caracters can remain in the keyboard buffer, so it will mess with
another scanf() calls if you don't use fflush(stdin) before them.
(this is what I can remember, please someone correct me if I said something
incorrect :-) )
Daniel K. O.
_______________________________________________________________________
Yahoo! PageBuilder
O super editor para criação de sites: é grátis, fácil e rápido.
http://br.geocities.yahoo.com/v/pb.html
|