/* Some more experimenting with file descriptors. */ /* Note that nothing happens to the file if we don't specify one of the three Modes in the printf */ #include #include #include #include main(argc,argv) int argc; char *argv[]; {int fd; char *buf=(char *)malloc(10); char *bufa=(char *)malloc(10); if (argc!=2) { printf("Enter a file name!!!\n"); exit(1); } strcpy(buf,"SUCCESS!!!\n"); // fd=open(argv[1],O_CREAT|O_TRUNC,0600); fd=open(argv[1],O_WRONLY,0600); // printf("No O_RDONLY Nor O_WRONLY Nor O_RDWR Descriptor # %d\n",fd); printf("Descriptor # %d\n",fd); write(fd,buf,7); write(fd,buf,11); close(fd); }