K
Kevin C.
Can someone explain why the file output produces all zeros? It seems to work
fine in memory (e.g. passing char pointers to printf) but when I output the
file, it comes out as zeros. Bookkeeping seems correct (counts, sizes, etc.)
and the output file is the correct size, just all zeros.
cd_entry *src = (cd_entry*)(tpd + tpd->cd_offset);
cd_entry *dest = (cd_entry*)(cur + cur->cd_offset);
for(int i = 0; i < tpd->num_columns; i++)
{
*dest = *src;
dest += sizeof(cd_entry);
src += sizeof(cd_entry);
}
newlist->num_tables++;
free(g_tpd_list); // deallocate old memory
g_tpd_list = newlist;
//output to file
FILE *fhandle = fopen("dbfile.bin", "wbc");
if(fhandle == NULL)
return FILE_OPEN_ERROR;
fwrite(g_tpd_list, g_tpd_list->list_size, 1, fhandle);
fflush(fhandle);
fclose(fhandle);
fine in memory (e.g. passing char pointers to printf) but when I output the
file, it comes out as zeros. Bookkeeping seems correct (counts, sizes, etc.)
and the output file is the correct size, just all zeros.
cd_entry *src = (cd_entry*)(tpd + tpd->cd_offset);
cd_entry *dest = (cd_entry*)(cur + cur->cd_offset);
for(int i = 0; i < tpd->num_columns; i++)
{
*dest = *src;
dest += sizeof(cd_entry);
src += sizeof(cd_entry);
}
newlist->num_tables++;
free(g_tpd_list); // deallocate old memory
g_tpd_list = newlist;
//output to file
FILE *fhandle = fopen("dbfile.bin", "wbc");
if(fhandle == NULL)
return FILE_OPEN_ERROR;
fwrite(g_tpd_list, g_tpd_list->list_size, 1, fhandle);
fflush(fhandle);
fclose(fhandle);