This is a two-part problem. The first bit of code creates an array of struct, initializes the various bits, and then displays them using a pointer.
]#include <iostream>
using namespace std;
const int SIZE=30;
const int bSIZE=3;
void Initialize(struct Book*[], int size);
struct Book
{char title[SIZE], author[SIZE];};
int main()
{
int choice1, choice2;
Book book[3]={{"None","None"},{"None","None"},{"None","None"}}
When I need to create a standard array of struct "book" at compile time, it is very simple and tidy. I can't get my mind around how to initialize a pointer to an array of struct.
#include <iostream>
using namespace std;
const int SIZE=30;
const int bSIZE=3;
void Initialize(struct book*[], int size);
struct Book
{char title[SIZE], author[SIZE];};
int main()
{
int choice1, choice2;
Initialize();
// I know I can create a function to initialize the value, but I don't know
//what I need to put in the parameter.
system ("pause");
return 0;
}
void Initialize(char Book *[],int size) // I have to use this function.
{
for(i=0; i<size; i++)
{
//can you fill this function? title and author have to be "None" "None".
}
}