I've been working on Fifteen, and I want to insert the values into an array (in init) but for some reason, it doesn't know what 'new' is. When I try #include <new>
, it says it cannot find said file. Here's my code for init():
int** init(int d)
{
int** field = 0;
field = new int*[d]; //line 163
int square = d*d - 1;
int tempSquare = square;
for(int i = 0; i < d; i++) {
field[i] = new int[d];
for(int j = 0; j < d; j++) {
field[i][j] = tempSquare;
tempSquare--;
}
}
return field;
}
When I make
said code, I get the following error message:
fifteen.c:163:13: error: use of undeclared identifier 'new'
field = new int*[d];
(I marked line 163 in init for you) Could someone maybe tell me how I can fix this error. I've been sitting on it for a few hours now and haven't found an answer myself, sadly.