Reading bit and converting to string

Jams's Avatar, Join Date: Apr 2010
Newbie Member
Hi
I just learned bitshifts and I was wondering whether it is possible to read bits and to convert them into a string.

Regards
Jamil
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Yes it is.
0
Jams's Avatar, Join Date: Apr 2010
Newbie Member
How would someone go about doing it?
0
Player's Avatar, Join Date: Aug 2007
Go4Expert Member
Quote:
Originally Posted by Jams View Post
How would someone go about doing it?

This takes 12 in dec, 2 is the base to be used (binary) and is then stored in the str array.

Code: CPP
int main(void)
{
    char str[4];
    printf("12 to binary is %s\n",itoa(12,str,2));
    return(0);
}

Last edited by SaswatPadhi; 16Apr2010 at 11:08.. Reason: Missing CODE tag