Newsgroups: comp.os.msdos.djgpp From: news AT hermes DOT hrz DOT uni-bielefeld DOT de (News Administrator) Subject: The size of structures and binary files Message-ID: <33A1B030.309E@post.psychologie.uni-bielefeld.de> Date: Fri, 13 Jun 1997 20:40:16 GMT Reply-To: mheumann AT post DOT psychologie DOT uni-bielefeld DOT de Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Nntp-Posting-Host: psyhk1ae01.uni-bielefeld.de Mime-Version: 1.0 Organization: Universität Bielefeld Lines: 26 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Dear DJGPP users! Recently I came across something weird: I have two structs: struct s1 { char c1; char c2; short s}; struct s2 { char c1; short s; char c2}; A call to sizeof will return 4 for s1 and 6 (!) for s2. It seems like the size of the chars in s2 gets increased to 2. Now I wouldn't care much, if it weren't for writing and reading these structs to binary files. A file containing s1 will have 4 bytes, while a file with s2 will have six. I have to access binary files, which were created with a program someone else wrote (and compiled), and it seems like his program would count 4 bytes for both sizes. The binary files are rather huge and contain several big structs. Does anybody know of a compiler option or some other way to get DJGPP to use 1 byte chars regardless of their context? You could really do me a great favour! Manni Heumann Bielefeld, Germany