diff options
-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); + } +} |