I'm trying to write a program that would read a dbase III file as input and make some changes according to the need of the user (delete a record, delete a field...). Anyways, what I am doing is the following:
1) reading the dbase III file
2) creating a hex dump out of it
3) reading the hex dump and making changes to the hex dump
now, what i need to do first is make sure that dump corresponds to one of dbase III file (the first byte represents the version of the dbase III file: it should be "03" )
I have wrote a test program that should make such checkings but it doesn't seem to work...
int main (int argc, char *argv)
char dd; } modify;
int number_of_records ; /* 32 bits */
printf ("sizeof header = %d\n", sizeof(header) );
printf("Enter file name:");
fd = fopen ( filename, "rb");
if ( fd == NULL )
printf ("Unable to open file %s\n", filename);
/* read the first part of the header information */
/* and verify that it is a dbase III file */
fread ( &header, 1, sizeof ( header ), fd );
if ( header.version != 3 ) /* what about 0x83 */
printf ("not a dbase 3 file, found %x\n", header.version );
printf ("Date last updated: %2.2d/%2.2d/%2.2d\n",header.modify.mm, header.modify.dd, header.modify.yy );
fclose ( fd );
} /* end of main */
I have attached a sample hex dump of a dbase III file.
Anybody knows why this is not working???