home *** CD-ROM | disk | FTP | other *** search
- main() /* open.c -- demonstrates open() */
- {char name[20];
- char buf[1];
- int fin;
-
- printf("Name please: ");
- gets(name);
- if ((fin = open(name,0)) == -1)
- { printf("No such file: %s\n",name);
- exit();
- }
- while(read(fin, buf, 1) >= 0)
- if (buf[0] == 26) exit();
- else putchar(buf[0]);
- close(fin);
- }