#include #include int main(int argc, char *argv[]){ if(argc < 2){ fprintf(stderr, "Usage %s filename\n", argv[0]); return 1; } // int fd = open(argv[1],O_RDONLY); //printf("File descriptor %d\n", fd); FILE *f = fopen(argv[1],"r"); if(f == NULL) { fprintf(stderr, "Could not open file %s Error code %d\n", argv[1], errno); perror("ERROR"); // fprintf(stderr, "ERROR: %s\n", strerror(errno)); return 1; } int c; while((c = fgetc(f)) != EOF){ printf("%c", c); } // while(read(fd, &c, 1) > 0){ // printf("%c", c); // } fclose(f); return 0; }