#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const char *CharToBin(int Caracter) {
static char Binario[9];
int i;
Binario[0] = '\0';
for (i = 128; i > 0; i >>= 1) {
strcat(Binario, ((Caracter & i) == i) ? "1" : "0");
}
return Binario;
}
int main(void) {
char Cadena[150];
int i;
printf("Ingrese PALABRA a convertir: ");
scanf("%s", &Cadena);
printf("\n\n\tCadena en binario:\n\n");
for (i = 0; i < strlen(Cadena); i++) {
printf("%s ", CharToBin(Cadena[i]));
}
printf("\n\n\n");
system("pause");
return 0;
}
Convertir una palabra en su representación binaria.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.