home *** CD-ROM | disk | FTP | other *** search
-
- char buffer[1000];
- int length;
- char *pc;
- FILE *file;
- file = fopen("CHARDATA.DAT","r");
- for (i = 0; i < 200; i++)
- {
- /* For each element */
- /* Read one line */
- fgets(buffer, 1000, file);
- /* Determine the length */
- length = strlen(buffer);
- /* Put a NUL character over the new-line '\n' */
- buffer[length - 1] = 0;
- /* Allocate space for the string */
- pc = malloc(length);
- /* Copy the string */
- strcpy(pc, buffer);
- /* Assign the pointer to an element */
- OBJECT[i].Element_1 = pc;
-
- /* Begin repetition for next element */
- ...
- }
-
-