#include #include #include int main(int argc, char** argv) { // file I/O example // open the file for reading int fd = open("a.txt", O_RDONLY); if (fd < 0) { printf("error opening file\n"); return -1; } int nread; char buf[1024]; // no string class in C while ((nread = read(fd, buf, sizeof(buf))) > 0) { // nread is the number of bytes read into buf write(1, buf, nread); // write nread bytes from buf to stdout } // done with the file, close the open file close(fd); return 0; }