TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: DANIEL LYNES
from: JAVIER KOHEN
date: 1997-08-07 21:02:00
subject: Re: Me again.. HEEEELPPPP!! It`s broken!21:02:1708/07/97

On 25-Jul-97, Daniel Lynes wrote to Wade Carpenter about Re: Me again.. 
HEEEELPPPP!! It's broken!.
 WC>> char msg[88];
 WC>> char fspec[50];
 WC>> fp = fopen("ZS.CFG","wt");
 WC>> fwrite(gets(msg),88,1,fp);
 WC>> fwrite(gets(fspec),50,1,fp);
 DL> As you can clearly see, 'msg' and 'fspec' are never initialized.
Yes they are. He initilizes 'em trough gets().
 DL> fspec[] variables in the working version.  The non-working version was 
 DL> only not initialized, but it did not contain any null bytes at the end 
of 
 DL> string.  When the user presses '' to end the gets() call, a null 
byte 
 DL> not appended to the result, because the null byte was never entered; 
only 
 DL> the newline.
Hey!!! :-)
gets() changes the '\n' entered with a '\0'.
BTW, it is the NUL character, not the NULL byte.
BTW2, you shouldn't use gets(), try fgets() or some C++ class instead.
Javier Kohen  [The_Crusher] http://jkohen.base.org
... I bet the Doctor could *confuse* the Borg.
-!- CrusherTag 0.3.2.
--- Terminate 4.00/Pro
---------------
* Origin: The King of The Ring (4:900/748.3)

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