fork(1) download
#include <stdio.h>
#include <stdlib.h>

static void errExit(const char *s)
{
    perror(s);
    exit(-1);
}

int main()
{
    const int base = 16;
    const int height = 5;
    const int width = 3;
    const int csize = 3;
    const char *fntPath = "moji.txt";
    const char *outPath = "date.txt";
    char fnt[base][height][width][csize];
    char buf[8];
    int c, i, j, k;
    FILE *p;

    p = fopen(fntPath, "r");
    if (p == NULL)
        errExit(fntPath);
    for (i = 0; i < base; i++)
        for (j = 0; j < height; j++)
            for (k = 0; k < width; k++) {
                fnt[i][j][k][0] = 0xE2;
                c = fgetc(p);
                switch(c) {
                    case '0':
                        fnt[i][j][k][1] = 0x80;
                        fnt[i][j][k][2] = 0x95;
                        break;
                    case '1':
                        fnt[i][j][k][1] = 0x97;
                        fnt[i][j][k][2] = 0x8F;
                        break;
                    default:
                        fclose(p);
                        if (c < 0)
                            errExit(fntPath);
                        else {
                             printf("%s: illegal character\n", fntPath);
                             return -1;
                         }
                }
                if (fseek(p, 1, SEEK_CUR) == EOF) {
                    fclose(p);
                    errExit(fntPath);
                }
            }
    if (fclose(p))
         errExit(fntPath);

    p = fopen(outPath, "w");
    if (p == NULL)
         errExit(outPath);
    for (i = 0; i < 5; i++) {
        for (j = 0; j < sizeof(buf); j++)
            buf[j] = rand() & 15;
        for (j = 0; j < height; i++) {
            for (k = 0; k < sizeof(buf); k++) {
                fwrite(fnt[buf[k]][j], csize, width, stdout);
                if (fwrite(fnt[buf[k]][j], csize, width, p) <= 0) {
                    fclose(p);
                    putchar('\n');
                    errExit(outPath);
                }
            }
            fputc('\n', stdout);
            if (fputc('\n', p) < 0) {
                fclose(p);
                errExit(outPath);
            }
        }
    }
    if (fclose(p))
        errExit(outPath);

    return 0;
}
Runtime error #stdin #stdout #stderr 0s 2136KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
moji.txt: No such file or directory