Declaring an array of negative length

前端 未结 3 1960
谎友^
谎友^ 2020-11-30 14:38

What happens in C when you create an array of negative length?

For instance:

int n = -35;

int testArray[n];

for(int i = 0; i < 10; i++)
    test         


        
3条回答
  •  离开以前
    2020-11-30 15:19

    Visual studio erro message for compilation, you can use -1 to say an empty array. It expects int and you are passing int, so no compiler error.

提交回复
热议问题