Search:
Forum
General C++ Programming
im having problems in arrays
im having problems in arrays
Oct 22, 2015 at 2:19pm UTC
cplusplusidiot
(3)
lets say u have
int x[12]
how to make all the 13 x equal to one value
example
x[0] = 2
x[1] = 2
x[2] = 2
x[3] = 2
how to do that in one line
Oct 22, 2015 at 2:51pm UTC
ne555
(10692)
> int x[12]
> how to make all the 13 x
no, they are only 12 elements. It goes from x[0] to x[11]
to set them all, use a loop or std::fill
http://www.cplusplus.com/reference/algorithm/fill/
Oct 23, 2015 at 4:37am UTC
Mikecnoob
(2)
do
int x[13]={1};
Oct 23, 2015 at 5:43am UTC
jlb
(4973)
do
int x[13]={1};
Ah, no. That will only initialize x[0] with 1, all other elements will be default initialized to 0.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs