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".
	}
		

}

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. 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".
	}
		

}

Can you put the code? The void function will dynamically allocate three struct Book objects and the address of the first struct Book object will be assigned to the first array element, the address of the second struct Book object will be assigned to the second array element, and so forth. The default value for the title and author fields should be "None"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.