1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>

int main(int argc, char* argv) {
  char buf[16*1024];

  int fd = open("file", O_RDONLY);

  int got, i, last_space = 1;

  while((got = read(fd, buf, sizeof(buf))) > 0) {
    for (int i = 0; i < got; ++i) {
      int this_space = isspace(buf[i]);
      if (last_space && !this_space) 
        buf[i] = toupper(buf[i]);
      last_space = this_space;
    }
    int ignore = write(1, buf, got);
  }
  return 0;
}