home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_11 / 8n11106c < prev    next >
Text File  |  1990-08-09  |  686b  |  27 lines

  1.  
  2.    char buffer[1000];
  3.    int length;
  4.    char *pc;
  5.    FILE *file;
  6.    file = fopen("CHARDATA.DAT","r");
  7.    for (i = 0; i < 200; i++)
  8.        {
  9.        /* For each element */
  10.        /* Read one line */
  11.        fgets(buffer, 1000, file);
  12.        /* Determine the length */
  13.        length = strlen(buffer);
  14.        /* Put a NUL character over the new-line '\n' */
  15.        buffer[length - 1] = 0;
  16.        /* Allocate space for the string */
  17.        pc = malloc(length);
  18.        /* Copy the string */
  19.        strcpy(pc, buffer);
  20.        /* Assign the pointer to an element */
  21.        OBJECT[i].Element_1 = pc;
  22.  
  23.        /* Begin repetition for next element */
  24.        ...
  25.        }
  26.  
  27.