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) {
The working solution for Integer number to binary conversion is below.
int main() { int num=241; //Assuming 16 bit integer for(int i=15; i>=0; i--) cout<<((num >> i) & 1); cout<> i) & 1); cout<
You can capture the cout<< part based on your own requirement.