/* #UselessProgram */
/* Touch */
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main() {
int x = 0;
char old[99], new[99];
srand(arc4random());
while (1) {
int y = x + rand() % 2 * 2 - 1;
snprintf(old, 99, "%d", x);
snprintf(new, 99, "%d", y);
if (-1 == rename(old, new) && ENOENT == errno)
x = y;
}
}
Today's #UselessProgram is to enumerate all images. https://github.com/ccshan/useless/commit/152556d7d5cea89f8528edb92b4ce05599944709
Finally wrote another #UselessProgram https://github.com/ccshan/useless/blob/c26b1236475599c9170279a0efb57d5e93a60390/scramble.rkt
/* #UselessProgram */
/* Silencing */
#include <stdio.h>
#include <stdlib.h>
const char A[] = "A", B[] = "B", C[] = "C";
int main() {
char buf[1000];
srand(arc4random());
if (fgets(buf, sizeof(buf), stdin)) {
for (char *c = buf; *c; ++c) {
switch (*c) {
case 'A': *c = A[rand() % sizeof(A)]; break;
case 'B': *c = B[rand() % sizeof(B)]; break;
case 'C': *c = C[rand() % sizeof(C)]; break;
default : *c = ' ';
}
}
fputs(buf, stdout);
}
return 0;
}