How to declare a variable size 2D array in C?

前端 未结 3 1294
太阳男子
太阳男子 2021-01-02 10:07

I have a problem with a project. I have to make a variable size 2D array for storing some prediction error..so this is about images. The trouble is that I have to load image

3条回答
  •  难免孤独
    2021-01-02 10:55

    You need to allocate memory dynamically. Use double pointer logic.

    Ex:

    int n=10; <<-u can change this.
    int **a;
    a=(int **)malloc(sizeof(*int)*n);
    for (int i=0;i

提交回复
热议问题