Date: Tue, 13 Jan 98 16:42:02 PST From: Noam Rotem Subject: Bit fields in djgpp To: djgpp AT delorie DOT com Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk Hello, When I use bit fields within a struct, initialize them and print the values, I get undefined non zero values. For example: struct { int x : 1; int y : 1; int z : 1; }Test={0,0,0}; main() { .... Test.x=1; printf("%d",Test.x); ... } I usually get -1 as an output, or other non zero values. I can live with non zero undefined values, but I would like to know the reason for the results I get. Should I declare bit fields as unsigned? char? something else? Should I use other format then "%d" for printing it? --------------------------------------------- Noam Rotem John Bryce Training Centre Tel Aviv, Israel. 03-7535803 ============================================= 1. Take upon yourself an impossible mission. 2. Accomplish the mission. 3. Go back to step 1. It's the only sane answer to modern life. --- 13/01/98 16:42:02