title: C - print file using system calls?
body: <p>I'm trying to get aquainted with system calls and C. I'm trying to read a file and write all the contents to the command line. I'm trying</p>
  
  <pre><code>int handle = open("./test.txt", O_RDONLY, O_TEXT);
  char buf[1];
  lseek(handle, 0, SEEK_SET);
  while (0 != read(handle, buf, 1)) {
          printf(*buf);
  }
  </code></pre>
  
  <p>This ALMOST works, except that it adds some gibberish characters after each character read from the file. For example if the file contains <code>asd asd</code> this writes <code>a:_s:_d:_ :_a:_s:_d</code> to the console. Any idea why? How can I fix it? </p>