muser wrote:
>
>
> This chunk of code doesn't do what it is suppose to do.
>
> if(!checkdigitforcustomercode( Newcrecord.customercode )){
> prnfile<< "Invalid: Incorrect check digit for c record\n";
> prnfile<< record << endl;
> return false;
> }
> else
> {
> validdata.write((char*) record, Newcrecord.customercode[5]);
> }
> the function works (checkdigitforcustomercode), but the
> validdata.write part doesn't write to the intended file. Can anyone
> tell me why they think that is?
For one you posted a littel bit to less information.
But remembering a little bit on what you posted through the last
weeks
> record is a character array. And Newcrecord.customercode[5] is a
> structure member.
When will you learn it eventually.
If you have an array
char customercode[5];
Then valid array indices in this array are:
customercode[0]
customercode[1]
customercode[2]
customercode[3]
customercode[4]
count them! There are 5 of them! The highest valid index into
an array is always 1 less then the number you specified when
defining that array.
One should think that you have learned that lesson after posting
that same mistake now for weeks and beeing corrected for it, again
for weeks.
The write itself looks suspicious:
> validdata.write((char*) record, Newcrecord.customercode[5]);
write to validdata, start at the starting address of the variable 'record'
and write Newrecord.customercode[5] number of bytes to it.
That doesn't look right. What has a customers code to do with how many
bytes of record are written to a file?
Why don't you hire a programmer writing this program for you?
He could have finished it since months.
--
Karl Heinz Buchegger