#include <stdio.h>
#include <ctype.h>
#define MASK 0x20
int myUpper(int c) {
return c & ~MASK;
}
int myLower(int c) {
return c | MASK;
}
#undef MASK
#define MASK 0x80
void bitDisp(char c) {
int i;
for (i = 0; i < 8; i++) {
putchar ((c & 0x80) ? '1' : '0');
c <<= 1;
}
}
int main() {
char *str1 = "the quick brown fox jumped over the fence";
char *str2 = "THE QUICK BROWN FOX JUMPED OVER THE FENCE";
char *p, c;
for (p = str1; *p; p++) {
if (isalpha((int)(c = *p)))
putchar(c = myUpper(c) & 0xff);
else
putchar(c);
putchar(':');
bitDisp(c);
putchar('\n');
}
putchar('\n');
for (p = str2; *p; p++) {
if (isalpha((int)(c = *p)))
putchar(c = myLower(c) & 0xff);
else
putchar(c);
putchar(':');
bitDisp(c);
putchar('\n');
}
return 0;
}
/* end */