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 177 views
1 answer 203 views
1 answer 205 views
1 answer 77 views
77 views asked Nov 18, 2024 by avibootz
2 answers 107 views
1 answer 168 views
168 views asked Nov 27, 2019 by avibootz
1 answer 177 views
177 views asked Nov 27, 2019 by avibootz
...