Library /sys$common/syshlp/helplib.hlb  —  CRTL  read  Example
        #include <unistd.h>
        #include <stdlib.h>
        #include <stdio.h>
        #include <fcntl.h>

        main()
        {
            int fd,
                i;
            char buf[10];
            FILE *fp ;          /* Temporary STDIO file */

            /* Create a dummy data file  */

            if ((fp = fopen("test.txt", "w+")) == NULL) {
                perror("open");
                exit(1);
            }
            fputs("XYZ\n",fp) ;
            fclose(fp) ;

            /* And now practice "read" */

            if ((fd = open("test.txt", O_RDWR, 0, "shr=upd")) <= 0) {
                perror("open");
                exit(0);
            }

            /* Read 2 characters into buf.  */

            if ((i = read(fd, buf, 2)) < 0) {
                perror("read");
                exit(0);
            }

            /* Print out what was read.  */

            if (i > 0)
                printf("buf='%c%c'\n", buf[0], buf[1]);

            close(fd);
        }
Close Help