Ok.. Here's the problem. This code is meant to write 138 bytes of
nformation
to a file, "ZS.CFG" but it writes whatever is entered plus garbage, or
sometimes it make a couple of extra lines, make a 139 byte file, or sometimes
it writes the first fwrite plus garbage and not the second one. Either way,
t
doesn't work. I am just distraught here. I've picked it apart from top to
bottom and I can't figure out what's up.. I have other code, which is almost
the exact same, but it works all of the time. I only cannot enter input, as
in
this one. That code is the second included bit.
DOESN'T WORK:
#include
void main(void)
{
FILE *fp;
char msg[88];
char fspec[50];
fp = fopen("ZS.CFG","wt");
fwrite(gets(msg),88,1,fp);
fwrite(gets(fspec),50,1,fp);
fclose(fp);
printf("Done!\r\n");
}
WORKS:
#include
#include
#include
#include
#include
#include
#include
#include
void main(void)
{
FILE *fp;
fpos_t filepos;
char *fn = "zs.cfg";
char msg[88] = "None";
char fspec[50] = "None";
fp = fopen(fn,"wt");
fwrite(msg,88,1,fp);
fwrite(fspec,50,1,fp);
fclose(fp);
}
If anyone can help me, I'll be very appreciative.
Thanks in advance!! cya
... My software never has bugs. It just develops random features...
---
---------------
* Origin: Alley Drive Software, Maple Ridge BC - 604-463-1776 (1:153/265)
|