summaryrefslogtreecommitdiff
path: root/Userland/tr.cpp
blob: 36b294318fce6e20994f7ebb3807e258d1edf091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <AK/AKString.h>
#include <AK/QuickSort.h>
#include <AK/Vector.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
    if (argc != 3) {
        printf("usage: tr <from> <to>");
        return 0;
    }

    char from = argv[1][0];
    char to = argv[2][0];

    for (;;) {
        char ch = fgetc(stdin);
        if (feof(stdin))
            break;
        if (ch == from)
            putchar(to);
        else
            putchar(ch);
    }

    return 0;
}