Dynamic array in Stack?

前端 未结 6 682
眼角桃花
眼角桃花 2020-11-27 21:25

Is this correct ? This is compiled with g++ (3.4) sucessfully.

int main()
{
    int x = 12;
    char pz[x]; 
}
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 22:24

    Technically, this isn't part of C++. You can do variable length arrays in C99 (ISO/IEC 9899:1999) but they are not part of C++. As you've discovered, they are supported as an extension by some compilers.

提交回复
热议问题