How to convert ASCII string to binary string C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
    char s[32] = "abcd";

    char bits[16];

    for (int i = 0; i < strlen(s); i++) {
        itoa(s[i] ,bits, 2);
        puts(bits);
    }
}




/*
run:

1100001
1100010
1100011
1100100

*/

 



answered Mar 12, 2022 by avibootz

Related questions

1 answer 260 views
1 answer 304 views
1 answer 302 views
1 answer 154 views
154 views asked Nov 18, 2024 by avibootz
2 answers 226 views
1 answer 269 views
269 views asked Nov 27, 2019 by avibootz
1 answer 289 views
289 views asked Nov 27, 2019 by avibootz
...