Archive for March 13, 2012

This is modified & compacted version from Balwinder, XLIAN3 and Gulnaz codes.

Thank you!!

char*  bits(int val){
  static char str[sizeof(int)*8+1];
  for(int size=sizeof(int)*8; size; val>>=1){
    str[--size]= (val & 1) + 48;
  }
  str[sizeof(int)*8]=0;
  return str;
}