Structure Array Searching help ~
First lets view the question...
Write a program to manage a database of information about an individual Compact Disc (CD) collection. Each entry includes the name of the group, the name of the CD, the year it was released, the price paid for it, and the total playing time.
- Allow the user to search for all the CDs released by a given group. Your program should able to display the CD detail based on the group name entered by the user.
- Allow the user to print aggregate information: the total cost of the collection.
__________________________________________________ __________________________________________________ ________________________
My coding so far...
Code:
#include <stdio.h>
#include <string.h>
#define NUM_CDS 100 // 100 hard-coded
struct CD {
char group_name[40];
char cd_name[40];
int year;
double price;
double playing_time;
}
main(void) {
int i, counter = 0;
char req_group[100];
char digimon[] = {0};
struct CD digimon[NUM_CDS];
strcpy(digimon[NUM_CDS].group_name, "Digimon");
strcpy(digimon[NUM_CDS].cd_name, "Digimon");
digimon[NUM_CDS].year = 1999;
digimon[NUM_CDS].price = 25.5;
digimon[NUM_CDS].playing_time = 25.5;
printf("Group Name: %s\nCD Name: %s\nYear: %d\nPrice: %.2lf\nPlaying Time: %.2lf",
digimon[NUM_CDS].group_name, digimon[NUM_CDS].cd_name, digimon[NUM_CDS].year, digimon[NUM_CDS].price, digimon[NUM_CDS].playing_time);
printf("Which cd you wish? ");
gets(req_group);
for(i=0;i<NUM_CDS;i++){
if( strcmp( digimons[i].group_name, req_group) == 0 )
}
return 0;
}
__________________________________________________ __________________________________________________ ________________________
Can someone guide me how to search the structure? And also what mean by print aggregate information? How can I print that? Very thanks you. :)