typedef struct device { char *name; } dev; int main (void) { FILE *fp; const int line_length=512; char config_line[line_length]; const char *filename="config.txt"; dev device_list[128]; int attr=0; int i=0; int num_devices=0; char device_name[32]; while (1) { if (NULL == (fp = fopen(filename, "r"))) { printf("file open failed for %s\n", filename); exit (EXIT_FAILURE); } while(fgets(config_line, sizeof(config_line), fp) != NULL) { sscanf(config_line, "%s %d", &device_name, &attr); device_list[num_devices].name=device_name; printf("device %d has name %s\n", num_devices, device_list[num_devices].name); ++num_devices; } fclose(fp); printf("num_devices read from configuration file: %d\n", num_devices); printf("printing array of structures\n"); for(i=0;i