TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DAVID VAN HOOSE
from: DAVID NOON
date: 1998-03-31 21:13:00
subject: Reading Input From Stdin

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.