Why is 248x248 the maximum bi dimensional array size I can declare?

后端 未结 3 1623
难免孤独
难免孤独 2020-12-02 00:48

I have a program problem for which I would like to declare a 256x256 array in C. Unfortunately, I each time I try to even declare an array of that size (integers) and I run

3条回答
  •  孤城傲影
    2020-12-02 01:24

    Unless you're running a very old machine/compiler, there's no reason that should be too large. It seems to me the problem is elsewhere. Try the following code and tell me if it works:

    #include 
    
    int main()
    {
      int ints[256][256], i, j;
      i = j = 0;
      while (i<256) {
        while (j<256) {
        ints[i][j] = i*j;
        j++;
       }
       i++;
       j = 0;
     } 
     printf("Made it :) \n");
     return 0;
    }
    

提交回复
热议问题