TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: TOM TORFS
from: DAVID VAN HOOSE
date: 1998-03-27 15:13:00
subject: reading input from stdin (was: I`m an id15:13:0003/27/98

-> RA> eg:
   RA> char name[40];
   RA> gets(name);
If you do that verbatim, you will have an overflow problem with all
known compilers.  This is how that should be:
char name[40];
gets(name);
name[40]='\n';
You have to put a NULL on the end or it will have an overflow problem.
I believe you have to do that with 'fgets' as well..
Just put the null character on the very end of the array.
Hope you like my advice. Peace!
-Dave van Hoose
1:3612/333
333:1/1
--- PCBoard (R) v15.3 (OS/2) 100
---------------
* Origin: Destiny BBS: LightBar Central (1:3612/333)

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