I have a problem with a program that I am writing.
What I intend is to open a file written in binary with account data, this includes a header with information of the data it contains. What I'm doing is reading that file and the data writing it into another file, as well as a backup.
I show a small part of the code:
typedef struct _Data{ long id; char nombre[50]; char email[50]; char cuenta[10]; float saldo; char estatus;; }Data;typedef struct _Header{ long filesize; long datasize; short offsetData; short headerSize; short regSize; char type[4]; }Header;
void* codigoHilo(void *param){
altas = fopen("Files/alta.bd","rb"); base = fopen("Files/Banco.bd","wb+"); rewind(altas); fread(&header,1,sizeof(header),altas); for(i=1;i<=(header.datasize/header.regSize);i++){ fread(&elementos,1,sizeof(Data),altas); fwrite(&elementos,1,sizeof(Data),base); printf("Dada de alta cuenta: %s \n",elementos.cuenta); }
When executing it, it reads the file without problem, but does not write anything in the bank file. Once the execution is finished, a 0 bytes file is created.
Someone can help me get back on track.
Thank you.