0

I have following code:

#include <iostream>
using namespace std;

class Table
{
     float time_table[800][600];
//   float player_table[800][600];

public:

Table(){}

void out(){
    for(int i;i<800;++i){
        for(int j;j<600;++j){
            time_table[i][j]=0.0;
    //      player_table[i][j]=0.0;
        }
    }
}

void change(float x, float y, float time, float player){
       time_table[int(x)][int(y)]=time;
//     player_table[int(x)][int(y)]=player;
}

void showtime(int i, int j){
    cout<<time_table[i][j];
}

//  void showplayer(int i, int j){
//      cout<<player_table[i][j];
//  }

};

int main(){

Table tab;
return 0;

}

and it seems to work. However, when I uncomment all the lines above it crashes. Can somenone explain me why? (I'm using Codeblocks 13.12 with GCC 4.8.1 on Windows) Thanks in advance.

user2280549
  • 1,204
  • 2
  • 12
  • 19
  • 2
    Crashes? How? Do you get any error messages? If so, what? – Frxstrem May 26 '15 at 22:41
  • 3
    The way you've done things, this is allocating all the space on the stack--you're almost certainly just running out of stack space. Obvious solution would be to create your 2D arrays as a vector + a thin layer to do the 2D addressing. – Jerry Coffin May 26 '15 at 22:43
  • Thanks guys for quick response! Sorry for duplicating - I haven't found this thread. Btw, is it possible to find out how big is stack (or maybe it's "hardware-software-dependent" issue)? – user2280549 May 26 '15 at 22:55

0 Answers0