Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Reading bit and converting to string (http://www.go4expert.com/forums/reading-bit-converting-string-t21719/)

Jams 9Apr2010 18:46

Reading bit and converting to string
 
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

xpi0t0s 10Apr2010 14:46

Re: Reading bit and converting to string
 
Yes it is.

Jams 12Apr2010 18:39

Re: Reading bit and converting to string
 
How would someone go about doing it?

Player 13Apr2010 17:48

Re: Reading bit and converting to string
 
Quote:

Originally Posted by Jams (Post 67007)
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);
}



All times are GMT +5.5. The time now is 21:08.