TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ANTHONY TIBBS
from: NEIL HELLER
date: 1998-02-01 10:10:00
subject: C++ SAVEDING STUFF

MM> char s[40];
MM> gets(s);
MM> puts("\r\nThis was the string you entered : "); puts(s);
AT> NO!  Never!  Bad!    You've allocated 40 bytes, but
AT> the user could easily type 4000.
AT> use:
 
AT> char s[40];
AT> fgets (s, 40, stdin);
AT> printf ("\n\nThis was the string you entered: %s\n", s);
That will STILL give a case of the nasties if the user enters 40
characters.  You must make room for the terminating null.
char s[41];
fgets(s,40,stdin);
 * KWQ/2 1.2i *
--- FLAME v1.1
---------------
* Origin: Port Chicago's Loading Dock - 510-676-5359 (1:161/204)

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™.