Search:
Forum
Beginners
array initialization problem
array initialization problem
Oct 19, 2009 at 12:30pm UTC
huzhanchi
(7)
hi everyone!
1
2
int
num=6;
int
s[num];
the compiler says:'s'unknown size.why this way cannot work.
thanks in advance.
Oct 19, 2009 at 12:36pm UTC
Bazzy
(6281)
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/
Oct 19, 2009 at 1:50pm UTC
huzhanchi
(7)
thank you.
you usually give me the answer and more than this.
Oct 19, 2009 at 3:06pm UTC
firedraco
(6243)
If you want to make a constant number, then you must specify it is
const
, e.g.
const
int
num = 6;
Oct 19, 2009 at 3:40pm UTC
huzhanchi
(7)
After i have a try ,i find the std::vector is very strong.(thanks also to firedraco
)
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs