Christoph (Derean's coworker) was presented with a daunting challenge: flip all of the bits of an integer (representing a bitfield) to zero. Many programmers would run away and never look back at just the thought of being given such a task. But not Christoph; being the courageous coder he was, he took this vexing problem head-on and engineered a rather elegant solution ...

#define GENBIT(x) 1<<X
#define NUMBITS 32

// ED: Snip ...

unsigned int resetBits(unsigned int bitfield)
  int index=0;
  {   unsigned int flag;
      flag = GENBIT(index);
      flag = ~flag;
      bitfield = bitfield & flag;
  return bitfield;
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!