array initialization problem

hi everyone!


1
2
int num=6;
int s[num];


the compiler says:'s'unknown size.why this way cannot work.

thanks in advance.
The size of an array must be a constant value. If you want a resizable array use std::vector or std::deque
http://www.cplusplus.com/reference/stl/
thank you.
you usually give me the answer and more than this.
If you want to make a constant number, then you must specify it is const, e.g.

const int num = 6;
After i have a try ,i find the std::vector is very strong.(thanks also to firedraco
)
Topic archived. No new replies allowed.