I\'m trying to convert an integer 10 into the binary number 1010.
This code attempts it, but I get a segfault on the strcat():
int int_to_bin(int k) {
Just use itoa to convert to a string, then use atoi to convert back to decimal.
unsigned int_to_int(unsigned int k) { char buffer[65]; /* any number higher than sizeof(unsigned int)*bits_per_byte(8) */ return atoi( itoa(k, buffer, 2) ); }