// Kris Cutsail CISC1O5 031 Terry Harvey / Peter Cline // DEATH PROJECT OF DOOM #include #include #include #define SET 100 typedef struct{ char name[SET]; char artist[SET]; char composer[SET]; char album[SET]; char genre[SET]; char size[SET]; char time[SET]; char trackNumber[SET]; char trackCount[SET]; char year[SET]; char playCount[SET]; } Music; Music structFill(FILE * data); void openFile(); void printStruct(Music jams[], int choice); void printStructArray(Music jams[]); int main(){ openFile(); return 0; } Music structFill(FILE * data){ char *next; char maintain[SET]; Music song[SET]; int count = 0; while(!feof(data)){ fgets(maintain, SET, data); next = strtok(maintain, ",\n"); while (next != NULL){ strcpy(song[count].name, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].artist, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].composer, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].album, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].genre, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].size, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].time, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].trackNumber, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].trackCount, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].year, next); next = NULL; } next = strtok(next, ",\n"); while (next != NULL){ strcpy(song[count].playCount, next); next = NULL; } printf("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", song[count].name, song[count].artist, song[count].composer, song[count].album, song[count].genre, song[count].size, song[count].time, song[count].trackNumber, song[count].trackCount, song[count].year, song[count].playCount); count++; } return song[count]; } void openFile(){ char select; char newFile[SET]; Music songs[SET]; int count; printf("Would you like to use the default data? (y/n) "); scanf("%c", &select); if(select == 'y'){ FILE * hold = fopen("project3data.txt", "r"); songs[count] = structFill(hold); fclose(hold); } else{ printf("Please enter the name of the data file you wish to use: "); scanf("%s", newFile); FILE * open = fopen(newFile, "r"); songs[count] = structFill(open); fclose(open); } return; }