In a message dated 03-29-98, David Van Hoose said to Roger Scudder about
Reading Input From Stdin
Hi David,
DH>That was supposed to look like:
DH>char name[41];
DH>gets(name);
DH>name[41]='\0';
DH>printf("%s",name);
DH>My bad.
It still is, I'm afraid.
An array of size 41 has subscripts 0 thru 40, so the 3rd line has a
subscript out of bounds.
Moreover, the gets() function does not limit the transfer to the size of the
supplied buffer, since it does not know that size. The use of fgets()
instead is much safer.
Regards
Dave
___
* MR/2 2.25 #353 * I'll never forget the first time I ran Windows, but I'm
trying!
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|