[C] this is ascii btw[C] this is ascii btw

🧑‍🚀

A Human Message

Week 4, 2026

#include #include #include int main() { char inString[1024]; scanf("%s", inString); int len = strlen(inString); int numNibbles = len / 4; // Arrays to store the intermediate steps char hexStore[numNibbles + 1]; // 1 & 2: Process binary into Hex characters for (int i = 0; i < numNibbles; i++) { // Look at a 4-bit chunk char chunk[5]; strncpy(chunk, &inString[i * 4], 4); chunk[4] = '\0'; // Convert the 4-bit string to a hex char if (strcmp(chunk, "0000") == 0) hexStore[i] = '0'; else if (strcmp(chunk, "0001") == 0) hexStore[i] = '1'; else if (strcmp(chunk, "0010") == 0) hexStore[i] = '2'; else if (strcmp(chunk, "0011") == 0) hexStore[i] = '3'; else if (strcmp(chunk, "0100") == 0) hexStore[i] = '4'; else if (strcmp(chunk, "0101") == 0) hexStore[i] = '5'; else if (strcmp(chunk, "0110") == 0) hexStore[i] = '6'; else if (strcmp(chunk, "0111") == 0) hexStore[i] = '7'; else if (strcmp(chunk, "1000") == 0) hexStore[i] = '8'; else if (strcmp(chunk, "1001") == 0) hexStore[i] = '9'; else if (strcmp(chunk, "1010") == 0) hexStore[i] = 'A'; else if (strcmp(chunk, "1011") == 0) hexStore[i] = 'B'; else if (strcmp(chunk, "1100") == 0) hexStore[i] = 'C'; else if (strcmp(chunk, "1101") == 0) hexStore[i] = 'D'; else if (strcmp(chunk, "1110") == 0) hexStore[i] = 'E'; else if (strcmp(chunk, "1111") == 0) hexStore[i] = 'F'; } hexStore[numNibbles] = '\0'; // 3: Convert Hex pairs to ASCII characters for (int i = 0; i < numNibbles; i += 2) { // Take two hex digits (8 bits total) and convert to a byte char hexPair[3] = { hexStore[i], hexStore[i+1], '\0' }; // strtol converts the string base-16 to a long integer int asciiVal = (int)strtol(hexPair, NULL, 16); printf("%c", (char)asciiVal); } printf("\n"); return 0; }