From: brucew AT phoenix DOT net (Bruce) Newsgroups: comp.os.msdos.djgpp,comp.programming,comp.unix.programmer,comp.os.msdos.programmer Subject: Re: quickbasic record to c struct? Date: Tue, 10 Dec 1996 02:36:20 GMT Organization: BranPaul Systems Lines: 50 Message-ID: <58iij9$qsg$2@gryphon.phoenix.net> References: <58gksj$ign AT butterfly DOT hjs DOT com> NNTP-Posting-Host: dial201.phoenix.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In comp.programming glynis AT butterfly DOT hjs DOT com (John M. Flinchbaugh) wrote: >typedef struct sheet_s { > short int num; > cal_t dateout; > tim_t timeout; > cal_t datein; > tim_t timein; > char area; > char loc[35]; > char nature; > char aidststus; > char dist; > long int damage; > char personnel; > char trucks; > char deaths; > short int mutual; > char notes[56]; > char attend[100]; >} sheet_t; >my problem is that my c program says that the size of that >record is 224 bytes, while the quickbasic program is using >it as a 218-byte record. obviously, this won't due if the c >program is to read the files written by the old quickbasic >program. Your basic program is using word alignment(2 byte boundries), your C program is using quadword alignment (8 byte boundries). >what is the easiest way to correct this problem in the c >program, for the data files have already been written, and i >need to read them from c for conversion? i can't seem to >find an option to gcc to allow me to adjust the alignment. The easiest way is to change the struct alignment to word boundries, then you'll be fine. I'm not making any promises, but add this line in a header before your typedef: #pragma pack(2) If that won't do it, the choices are less appealing. You will have to either change the basic code or treat the C struct like a big string and pack it yourself. Bruce