Preview:
#include<stdio.h>
#include <fcntl.h>
int main()
{
  int fd, sz;
  char *c = (char *) calloc(100, sizeof(char));

  fd = open("f1.txt", O_RDONLY);
  if (fd = = -1)
   {
   perror("r1");
   exit(1);
   }
  sz = read(fd, c, 10);
  printf("called read(% d, c, 10).  returned that" " %d bytes  were read.\n", fd, sz);
  c[sz] = '\0';
  printf("Those bytes are as follows: % s\n", c);
  return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter