Hacker News new | past | comments | ask | show | jobs | submit login

No, that's not correct. It reads the string from standard input. A C translation would look like this:

    main()
    {
        int ch;
        while ((ch = read()) != 4) {
            if (ch > 0100 && ch < 0133)
                ch = ch + 040;
            if (ch == 015) continue;
            if (ch == 014) continue;
            if (ch == 011) {
               ch = 040040;
               write(040040);
               write(040040);
            }
            write(ch);
        }
    }
A more modern C version would look like:

    #include <stdio.h>

    int
    main(void)
    {
        int ch;
        while ((ch = getchar()) != -1) {
            if (ch > 0100 && ch < 0133)
                ch = ch + 040;
            if (ch == 015) continue;
            if (ch == 014) continue;
            // No need to handle tabstop specially
            putchar(ch);
        }
    }



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: