An ode to
Dennis Ritchie, of C and Unix fame, who died this week. A Unix command that echos the input characters and swaps the foreground and background colors after every 7th line break
#include <stdlib.h>
#include <stdio.h>
void main() {
int l = 0;
int c = 0;
char** f = malloc(sizeof (char*) * 2);
f[0] = "\033[0;7m";
f[1] = "\033[7;0m";
while ( ( c = getchar() ) != EOF ) {
if ( c == '\n' ) {
if ( l % 7 == 0 ) {
printf(f[l%2]);
}
l++;
}
putchar(c);
}
printf("\033[0m");
}
Unfortunately, with all candor, I am glad I don't code in C anymore.