]>
git.scottworley.com Git - tl-append/blob - tl-append.c
c2f476ff7e4cdb025e8bfca786f7c9e88abcb3ae
6 const size_t BUF_SIZE
= 1024;
8 static void read_line(char *buf
) {
9 if (fgets(buf
, BUF_SIZE
, stdin
) == NULL
) {
11 die("I/O error reading line");
13 buf
[0] = '\0'; /* Unclear if fgets does this already */
16 die("Unexpected error reading line");
20 static void write_line(const char *line
) {
21 FILE *f
= fopen(FILENAME
, "a");
23 die_err("Error opening output file");
24 if (fputs(line
, f
) == EOF
)
25 die("Error writing to output file");
27 die_err("Error closing output file");
32 for (read_line(buf
); buf
[0]; read_line(buf
)) {