Library /sys$common/syshlp/helplib.hlb  —  CRTL  fgets  Example
        #include <stdio.h>
        #include <stdlib.h>
        #include <unixio.h>

        main()
        {
            FILE *fp;
            char c_ptr[130];

            /* Create a dummy data file  */

            if ((fp = fopen("file.dat", "w+")) == NULL) {
                perror("open");
                exit(1);
            }

            fprintf(fp, "this is a test\n") ;
            fclose(fp) ;

            /* Open a file with some data -"this is a test"   */

            if ((fp = fopen("file.dat", "r+")) == NULL) {
               perror("open error") ;
                exit(1);
            }

            fgets(c_ptr, 130, fp);
            puts(c_ptr);        /* Display what fgets got.  */
            fclose(fp);

            delete("file.dat") ;
        }
Close Help