typedef struct {
char barcode [14];
char nam [21];
char dfName [ 9];
int unit ;
float price ;
long quant ;
char DatStr [ 6];
long Id ;
long found ;
} Itemrec;
Itemrec thisItem ;
when i try to write it to the file i read from using this command
myFile.write( &thisItem );
it changes the length of file and thus destroying the sequence
when i try to use
myFile.write( &thisItem, sizeof(thisItem) );
it gives me error >>>
SD_Card:79: error: no matching function for call to 'SDLib::File::write(Itemrec*, unsigned int)
i would appreciate if some one give me the right syntax
thank you
Why are you trying to write the address of the struct to the file? That's what the & operator gives you.
Just use:
myFile.write((byte *)thisIten, sizeof(Itemrec));
The cast is necessary because thisItem is not a byte array, but it can be treated like one, so we lie to the compiler, and tell it that thisItem IS a byte array.
thank you Paul for your help i tried the syntax you suggested but my compiler discovered i am lying and said "SD_Card:136: error: invalid cast from type 'Itemrec' to type 'byte* {aka unsigned char*}'"
i come from vb background so i am not well used to casting rules
i hope for more help
thanks again
fidamon