cannot initialize array..

I am getting an error message when i am trying to initialize an array.


1
2
3
4
5
6
7
8
9
10
int rute(int goalx , int goaly , int startx , int starty , int **array )
{
    int x = startx;
    int y = starty;
    int state= 0;
    int decision[4] = {0};
    decision = {array[x+1][y], array[x-1][y],array[x][y+1],array[x][y-1]};
   //Error ^^
return state
}
Last edited on
closed account (SECMoG1T)
decision = {array[x+1][y], array[x-1][y],array[x][y+1],array[x][y-1]};
you can only use intializer list on arrays for intialization not assigning, assign to an array like this is illegal;

you could simply intialize the array directly with the ntializer list
Last edited on
can this be done in any ways using other kind of lists?
Replace int decision[4] = {0}; with
int decision = {array[x+1][y], array[x-1][y],array[x][y+1],array[x][y-1]};
Topic archived. No new replies allowed.