#include <stdio.h>
#include <string.h>
int main(){
char mensagem[200];
printf("Digite a mensagem: "); fgets(mensagem
, 200, stdin
); mensagem
[strcspn(mensagem
, "\n")] = 0; int tamanho
= strlen(mensagem
); char vetor_binario[tamanho * 8 + 1];
vetor_binario[tamanho * 8 + 1] = '\0';
for (int i = 0; i < tamanho; i++) {
for (int j = 7; j >= 0; j--) vetor_binario[i * 8 + (7 - j)] = ((mensagem[i] >> j) & 1) + '0';
}
// for (int i = 0; i < tamanho * 8; i++) {
// printf("%c", vetor_binario[1]);
// }
}
//https://pt.stackoverflow.com/q/216284/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKCl7CgljaGFyIG1lbnNhZ2VtWzIwMF07CiAgICBwcmludGYoIkRpZ2l0ZSBhIG1lbnNhZ2VtOiAiKTsKICAgIGZnZXRzKG1lbnNhZ2VtLCAyMDAsIHN0ZGluKTsKICAgIG1lbnNhZ2VtW3N0cmNzcG4obWVuc2FnZW0sICJcbiIpXSA9IDA7CglpbnQgdGFtYW5obyA9IHN0cmxlbihtZW5zYWdlbSk7CgljaGFyIHZldG9yX2JpbmFyaW9bdGFtYW5obyAqIDggKyAxXTsKCXZldG9yX2JpbmFyaW9bdGFtYW5obyAqIDggKyAxXSA9ICdcMCc7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IHRhbWFuaG87IGkrKykgewogICAgCWZvciAoaW50IGogPSA3OyBqID49IDA7IGotLSkgdmV0b3JfYmluYXJpb1tpICogOCArICg3IC0gaildID0gKChtZW5zYWdlbVtpXSA+PiBqKSAmIDEpICsgJzAnOwogICAgfQovLyAgICBmb3IgKGludCBpID0gMDsgaSA8IHRhbWFuaG8gKiA4OyBpKyspIHsKLy8gICAgcHJpbnRmKCIlYyIsIHZldG9yX2JpbmFyaW9bMV0pOwovLyAgICB9CiAgICBwcmludGYoIiVzIiwgdmV0b3JfYmluYXJpbyk7Cn0KCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzIxNjI4NC8xMDE=