hi,
is it possible to declare a structure as a reference parameter?
If it does, may I know why the following codes of mine
is wrong?
//initialisation
struct book_record
{
char ISBN[11];
char title[31];
char author[31];
char category[3];
char date[11];
float price;
};
struct BkArray
{
struct book_record BookArray[10];
};
void add_records(BkArray *library)
{
//variables
int number;
printf("\nEnter the number of records that you are going to enter: "
scanf("%d", &number);
for(int k = 0; k < number; k++)
{
printf("\n#%d Record:\n", k+1);
BarLine(30);
printf("Enter ISBN: "
gets( library.BookArray[k].ISBN);
printf("\nEnter the title of the book: "
gets( library.BookArray[k].title);
printf("\nEnter the author of the book: "
gets(library.BookArray[k].author);
printf("\nEnter the price of the book: "
scanf("%f", &library.BookArray[k].price);
printf("\nEnter the category of the book\n"
gets( library.BookArray[k].category);
printf("\nEnter the published date in the format of dd/mm/yyyy: "
gets (library.BookArray[k].date);
}//for
}//add_records
is it possible to declare a structure as a reference parameter?
If it does, may I know why the following codes of mine
is wrong?
//initialisation
struct book_record
{
char ISBN[11];
char title[31];
char author[31];
char category[3];
char date[11];
float price;
};
struct BkArray
{
struct book_record BookArray[10];
};
void add_records(BkArray *library)
{
//variables
int number;
printf("\nEnter the number of records that you are going to enter: "
scanf("%d", &number);
for(int k = 0; k < number; k++)
{
printf("\n#%d Record:\n", k+1);
BarLine(30);
printf("Enter ISBN: "
gets( library.BookArray[k].ISBN);
printf("\nEnter the title of the book: "
gets( library.BookArray[k].title);
printf("\nEnter the author of the book: "
gets(library.BookArray[k].author);
printf("\nEnter the price of the book: "
scanf("%f", &library.BookArray[k].price);
printf("\nEnter the category of the book\n"
gets( library.BookArray[k].category);
printf("\nEnter the published date in the format of dd/mm/yyyy: "
gets (library.BookArray[k].date);
}//for
}//add_records