TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DAVID VAN HOOSE
from: JOHN RICHARDSON
date: 1998-04-03 10:12:00
subject: reading input from stdin (was: I`m an id10:12:4004/03/98

Hi Dave
 DVH>> char name[40];
 DVH>> gets(name);
 DVH>> name[40]='\0';
 > 
 TT>> That still leaves the problem that you're writing to memory that
 TT>> isn't yours. Your array is only 40 characters long and you try to
 TT>> access the 41st element!
 > 
 > Actually it is correct.  I don't know where you see anything wrong, 
I think Tom means that name[40]='\0' should be name[39]='\0' since C/C++ is 
zero based (i.e 0 is always the first element hence 39 is the fortieth and 40 
is the fortyfirst).
John.
--- JetMail 0.99beta23
---------------
* Origin: The Dysfunctional Refrigerator (fidonet 2:2502/60)

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