All pastes #490207 Raw Edit

Something

public c v1 · immutable
·published 2007-05-15 22:02 UTC
rendered paste body
// Kris Cutsail CISC1O5 031 Terry Harvey / Peter Cline// DEATH PROJECT OF DOOM#include<stdio.h>#include<stdlib.h>#include<string.h>#define SET 100typedef 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;    }    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");    for(count = 0; count < SET; count++)      songs[count] = structFill(hold);    printStruct(songs, 0);    fclose(hold);  }  else{    printf("Please enter the name of the data file you wish to use: ");    scanf("%s", newFile);    FILE * open = fopen(newFile, "r");    for(count = 0; count < SET; count++)      songs[count] = structFill(open);    printStruct(songs, 6);    fclose(open);  }  return;}void printStruct(Music jams[], int choice){printf("%s, %s, %s, %s, %s\n",       jams[choice].name,       jams[choice].artist,       jams[choice].composer,       jams[choice].album,       jams[choice].genre); return;}void printStructArray(Music jams[]){  int count = 0;  while(jams[count].name != '\0'){    printStruct(jams, count);    count++;  }  return;}