TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: MANISH MALIK
from: GEORGE WHITE
date: 1998-02-04 09:28:00
subject: C++ Saveding stuff

Hi Malish,
You wrote to Anthony Tibbs:
MM>MM>> char s[40];
MM>MM>> gets(s);
MM>MM>> puts("\r\nThis was the string you entered : "); puts(s);
MM> AT> NO!  Never!  Bad!    You've allocated 40 bytes,
MM> AT> but the user could easily type 4000.
MM>okay, hows this piece of code ??
MM>char *s;
MM>gets(s);
MM>puts("\r\n Whether you typed 40 or 4000, I have it all ! Here - ");
MM>puts(s);
MM>Okay now ? :-)
Even worse :-(
As you have not allocated any storage space to store the string,
_anything_ entered will be likely to corrupt something.
George
 * SLMR 2.1a * All Trademarks acknowledged (just in case ).
--- 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™.