'ello
whenever i compile i keep getting an error saying identifier or declarator expected....for some reason i cant correct it neone know whats wrong???
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void filewrite(void);
void fileprint(struct tuple *myDB);
// Idea here is to enter an array of structures
// write them to disk and read them back
// simple structure
struct tuple {
char artist[50];
char album[50];
char label[50];
char year[4];
char type[30];
};
/*********************************************************************************************************/
void filewrite(void) {
// file pointer
FILE *mydata;
// structures
struct tuple myDB[3];
struct tuple otherDB[3];
// variable needed
int i;
i=1;
mydata = fopen("mymusic.dat","wb");
while(i) {
printf("Enter the artist name: \n");
scanf("%s",myDB[i].artist);
printf("Enter the album: \n");
scanf("%s",myDB[i].album);
printf("Enter label name: \n");
scanf("%s",myDB[i].label);
printf("Enter year: \n");
scanf("%d",&myDB[i].year);
printf("Enter the type of music: \n");
scanf("%s",&myDB[i].type);
fprintf(mydata, "%s %s %s %d %s\n",myDB[i].artist, myDB[i].album, myDB[i].label,myDB[i].year,myDB[i].type);
printf("\n\n press 1 to continue,0 to stop");
scanf("%d",&i);
}
// don't forget to close the file
fclose(mydata);
}
/********************************************************************************************/
void fileprint(struct tuple *myDB ){
FILE *mydata;
int i;
printf("reading data...\n");
mydata = fopen("mymusic.dat","rb");
{
fscanf(mydata,"%s %s %s %d %s",myDB[i].artist, myDB[i].album, myDB[i].label, &myDB[i].year, myDB[i].type);
printf("Record is...\n");
printf("%s\n",myDB[i].artist);
printf("%s\n",myDB[i].album);
printf("%s\n",myDB[i].label);
printf("%d\n",myDB[i].year);
printf("%s\n",myDB[i].type);
}
// close it again
fclose(mydata);
}
}
}
/*****************************************************************************************/
int main(void){
int c;
while(c!=6)
{
printf("GIVE CHOICE--\n");
printf(" 1 TO CD Information\n");
printf(" 2 TO Print Data On Screen\n");
printf(" 6 TO EXIT\n\n--");
scanf("%d",&c);
switch(c)
{
case 1:
filewrite();
break;
case 2:
fileprint();
break;
case 6:
break;
default:
break;
}
}
}