storing structure(size less than 1 byte) to file

sreejith's Avatar, Join Date: Nov 2007
Newbie Member
hi,
Plz replay .............for storing a structure(containing a 4 bit length variable) to a file
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
As you have posted the query in the introduce yourself forum no one can even make a guess which programming language you are looking help in. Help us to help you.
0
sreejith's Avatar, Join Date: Nov 2007
Newbie Member
hi,
thanks for your attention, C++ is the language which I forget to mention, can I store the structure (<1 byte) without using type casting. ................hoping your replay
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Moved to C-C++ forum.
0
Salem's Avatar, Join Date: Nov 2007
Ambitious contributor
You can't have a struct containing less than 1 byte in C or C++.

I'm guessing you declared a bit-field
Code:
struct foo {
  unsigned int bits : 4;
};
This will ALWAYS be padded to some multiple of the size of a char.

Show us some more of what it is you're trying to do.