K&R Exercise 1-19. Reverse program input one line at a time
Minor: 

getline()

When size is pathologically small (sz &lt;= 1), if (c == '\n') { tests the uninitialized c leading to  undefined behavior.  

With sz &lt;= 0, s[i] = '\0'; is not valid either.

I'd recommend to note the condition that sz &gt; 1 is expected.



Further, I'd use size_t rather than int for the buffer size and re-code to handle those edge cases.

size_t getline(char s[], size_t sz) {
    int c = 0;
    size_t i;

    for (i=0; i + 1 &lt; sz &amp;&amp; (c=getchar())!='\n' &amp;&amp; c!=EOF; ++i) {
        s[i] = c;
    }
    if (c == '\n') {
        s[i] = c;
        ++i;
    }
    if (i &lt; sz) {
      s[i] = '\0';
    }
    return i;
}