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)
|