Hello David.
27 Mar 98 15:13, David Van Hoose wrote to Tom Torfs: RA>> char name[40];
RA>> gets(name);
DVH> If you do that verbatim, you will have an overflow problem with all
DVH> known compilers. This is how that should be:
DVH> char name[40];
DVH> gets(name);
DVH> name[40]='\n';
DVH> You have to put a NULL on the end or it will have an overflow problem.
So then why did you put a newline on the end?
DVH> I believe you have to do that with 'fgets' as well..
No fgets prevents an overflow problem by limiting the number
of characters that it will copy to the array. There can be
a problem with character left over in stdin after a call to
fgets though, but that's easy to work around.
DVH> Just put the null character on the very end of the array.
That's one possible way to deal with it.
DVH> Hope you like my advice. Peace!
Thanks for sharing :-)
-Roger
--- Msged/386 4.20 beta 3kl3
(1:273/404@fidonet)
---------------
* Origin: Box Of Rotting Corpses BBS, Upper Darby, PA, USA
|