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