Mail Archives: djgpp/1998/01/13/09:58:06
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
- Raw text -