I have a pointer object consisting of different arrays of variable length. I want to get one of the arrays from the pointer array and store is in a different array. How would I go about doing it? When I try the method, it gives an error: initialization with '{...}' expected for aggregate objects which I assume means I am trying to convert from pointer to array type. Any ideas?

Here is a partial code.

int actionsfromA [] = {stateB, stateD};
int actionsfromB [] = {stateA, stateC, stateE};
int actionsfromC [] = {stateC};
int actionsfromD [] = {stateA, stateE};
int actionsfromE [] = {stateB, stateD, stateF};
int actionsfromF [] = {stateC, stateE};


// main arrays of states actions pairs
int* actions[] = {actionsfromA, actionsfromB, actionsfromC, actionsfromD, actionsfromE, actionsfromF};


void run()
{
//	rand() = 
	for (register int i = 0; i<1000;i++)
	{
		int state = rand () % stateCount;
		while (state != stateC)
		{
			int *actionsFromState [] = actions [state];



		}



	}




}

Is "stateB" a constant? The compiler may be whining that you are trying to initialize the array with dynamic data.

Is "stateB" a constant? The compiler may be whining that you are trying to initialize the array with dynamic data.

Np. It is a variable set equal to 1. None of the StateA/B... are constants. and the problem is here:

int *actionsFromState [] = actions [state];

I figured out my mistake. I made a new code without using dynamic arrays.

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.