Non-const declaration of array

后端 未结 8 875
你的背包
你的背包 2020-12-19 05:11

I have been teaching myself programming for couple of years, and I was sure that if you need array declaration of a variable number you need to use malloc or

相关标签:
8条回答
  • 2020-12-19 05:36

    See http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.20.

    Simply put, in C99, this is called VLA and is part of the standard (correct me if I'm wrong) but in C++ this is not part of the standard. If you need this functionality use std:vector instead.

    0 讨论(0)
  • 2020-12-19 05:37

    It's okay to use the feature if you are using c99.

    You have to be very careful about the value of size. a large value will overflow your stack, and your process may go insane.

    0 讨论(0)
提交回复
热议问题