Hi,
I want to make a stream file in pc with VC++.
The layout of records are as follows:
struct Log_record {
char sequence[8];
int index;
int cord;
char crlf[2];
}
Log_record my_rec;
char LogBuffer[sizeof(my_rec)*1000];
for (int i = 0;i<1000;i++)
{
CString s = _T("");
s.Format(_T("%07d"), i+1);
Widechartomultibyte(s,...., my_rec.sequence, 8, NULL,NULL);
my_rec.index = 0;;
my_rec.cord = 0;
my_rec.crlf = 0x0d0a;
memcpy(&LogBuffer[i*sizeof(my_rec), &my_rec, sizeof(my_rec));
}
So, after filling a LogBuffer with 1000 records, and fwrite with option as "ab" one time.
So I expect a file with structure like as following
0000001 ..... CRLF
0000002 ..... CRLF
.....
....
0001000 ...... CRLF
But, sometimes,
It make a file with space sequence or without CRLF.
It looks like broken records...
What is the cause of ths problem?
1. Simple coding mistake?
2. Or any other cause of PC?
Please help me.
Thank you in advance
What I have tried:
More 1 week wasted for this problem.