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];



7 Years
Discussion Span
Last Post by YodaMerlin

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];

Edited by YodaMerlin: fogot title.


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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.