c arrays: setting size dynamically?

后端 未结 4 796
余生分开走
余生分开走 2021-01-18 11:25

I am new to C programming. I am trying to set the size of the array using a variable but I am getting an error: Storage size of \'array\' isn\'t constant !!

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 12:04

    What you want is possible in C99; however, with earlier versions of C, you are stuck calling functions to dynamically allocate memory, e.g. alloca(3) or malloc(3).

提交回复
热议问题