Mail Archives: djgpp/1997/08/29/00:02:59
Robert Debeljakovic wrote:
>
> I typed this one in, and the following happened:
> How many dice? 1
> How many sides 10
> The result is -1892526920
>
> That must have been one helluva roll eh?
>
> Anyone know why I get this answer?
> I have checked the code? Its fine! (what little there is!)
No, it isn't. Please allow me to blush with humiliation, for I made a
silly mistake. Observe the following lines:
printf( "How many dice? " );
scanf( "%d", n );
printf( "How many sides? " );
scanf( "%d", s );
Note the arguments to scanf(). Put ampersands before n and s (&n, &s),
and the program will work fine.
When you compile with '-Wall', you catch these sorts of things. Sorry.
;)
--
---------------------------------------------------------------------
| John M. Aldrich | "Sin lies only in hurting other |
| aka Fighteer I | people unnecessarily. All other |
| mailto:fighteer AT cs DOT com | 'sins' are invented nonsense." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -