Reading bit and converting to string

Newbie Member
9Apr2010,18:46   #1
Jams's Avatar
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
Mentor
10Apr2010,14:46   #2
xpi0t0s's Avatar
Yes it is.
Newbie Member
12Apr2010,18:39   #3
Jams's Avatar
How would someone go about doing it?
Go4Expert Member
13Apr2010,17:48   #4
Player's Avatar
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