diff options
author | the lemons <citrons@mondecitronne.com> | 2022-03-08 14:14:06 -0600 |
---|---|---|
committer | the lemons <citrons@mondecitronne.com> | 2022-03-08 14:14:06 -0600 |
commit | 169152db5bfc993cd3a8bee12e2c28d010e4c91a (patch) | |
tree | 46b4f9c79c96bc43e0a72af0c45e45b0058390d3 | |
parent | 3520c964ecd7093ea4a7bdc30c3cc83585d129ab (diff) |
garbagifier
-rw-r--r-- | garbage.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/garbage.c b/garbage.c new file mode 100644 index 0000000..ab0afac --- /dev/null +++ b/garbage.c @@ -0,0 +1,20 @@ +// engarbage files + +#include <stdlib.h> +#include <stdio.h> +#include <time.h> + +int main(int argc, char *argv[]) { + time_t t; + srand(time(&t)); + + double rate = 0.5; + if (argc > 1) + rate = atof(argv[1]); + for (int c = fgetc(stdin); c != EOF; c = fgetc(stdin)) { + if ((double)rand() / (double)RAND_MAX < rate / 100) + fputc(c + 1, stdout); + else + fputc(c, stdout); + } +} |