I have a table availableRows which contains integers values. When I display the value of availableRows[0] for the first time, it shows the correct value. But then, in the for loop, it shows a completely different number which is 512.
What did I do wrong ?
    int row;
    int randomColumn;
    int *availableRows = getAvailableRows(); 
    cout << availableRows[0]; // It shows the correct value
for (int column = 0; column < COLUMN_GRID; column++){
    row = availableRows[column];
    cout << row; // But here it shows 512, why ?
    /* Simulates a winning point */
    if (row != -1 && simulateWin(row, column)){
        GRID[row][column] = COMPUTER;
        COUNT += 1;
        return;
    }
}
int *getAvailableRows(){
    int availableRows[7] = {-1, -1, -1, -1, -1, -1, -1};
for (int column = 0; column < COLUMN_GRID; column++){
    for (int row = 0; row < ROW_GRID; row++){
        if (GRID[row][column] == NONE){
            availableRows[column] = row;
            break;
        }
    }
}
return availableRows;
}
EDIT : I added the getAvailableRows() function.
Could somebody explain me why what I've done is bad ? I don't really understand pointers very well.
 
    