Hi i am trying to initialise my bitcontents in my structure to zero while making a new structure.My current method is not working .Any suggestions
Code:
/ a bit vector struct
struct bitset{
int size;
unsigned int *bitcontents;
char buffer[27];
};
/*initialisng a bitset struct to the size of the elements
*/
struct bitset * bitset_new(int size){
struct bitset * p= ( struct bitset *) malloc(sizeof(*p));
p->size=size;
p->bitcontents= (unsigned int*) malloc( (sizeof(int) * size/8) + (size % 8)? 1:0) ;
int i=0;
while(i<31){
p->bitcontents[i]=0;
i++;
}
return p;
}