mformazhar1980
Junior Member level 1
bit structure for arrays
hi
i am intending to make a bit structure that i am going to use for storing boolean data into a two dimensional array.
the problem is i dont know exactly which data type is suitable so that i could save memory. i have used uint8_t as a data type. all i need to check whether i am on right track or not.
i want to store bits i.e 1's and 0's in a two dimensional array.
is that really save only the bits in said array or is it saving the whole bit in the index?
i.e suppose Value[0][j] stores {1,1,1,1,1}or
Value[1][j] stores {0,0,0,0,0}
the code snippet is as follows
now the point is that how i can fetch all the data so that it can represent like
Value[0][j] stores all the 0's untill there is 1's appear and then it should immediately switches to Value[1][j] and store all the 1's there until the next change i.e occurrence of 0's again. and switches to Value[2][j] and store all the 0,s there and so on.
can any body help me to sort out the logic.
thanks
[/code]
hi
i am intending to make a bit structure that i am going to use for storing boolean data into a two dimensional array.
the problem is i dont know exactly which data type is suitable so that i could save memory. i have used uint8_t as a data type. all i need to check whether i am on right track or not.
i want to store bits i.e 1's and 0's in a two dimensional array.
is that really save only the bits in said array or is it saving the whole bit in the index?
i.e suppose Value[0][j] stores {1,1,1,1,1}or
Value[1][j] stores {0,0,0,0,0}
the code snippet is as follows
Code:
unit8_t Value[4][10];
typedef struct Save_Bits
{
uint8_t i :1;
uint8_t j :1;
} Save_Bits;
struct Save_Bits Value[i][j];
// then in the while loop get values
now the point is that how i can fetch all the data so that it can represent like
Value[0][j] stores all the 0's untill there is 1's appear and then it should immediately switches to Value[1][j] and store all the 1's there until the next change i.e occurrence of 0's again. and switches to Value[2][j] and store all the 0,s there and so on.
can any body help me to sort out the logic.
thanks
[/code]