|
From: Lloyd <ll...@cd...> - 2007-07-04 15:55:42
|
Thank you Rory, But I would like to know which one would be better (in execution) as you said > myvector.resize(10); > for(int i=0;i<10;i++) > myvector[i] = 0; > or myvector.clear() for(int i=0;i<10;i++) myvector.push_back(0); Thanks, Lloyd On Wed, 2007-07-04 at 16:43 +0100, Rory Walsh wrote: > You can use the resize() like this: > > myvector.resize(10); > for(int i=0;i<10;i++) > myvector[i] = 0; > > More details on vectors can be found here: > http://www.cppreference.com/cppvector/index.html > > regards, > Rory. > > Lloyd wrote: > > Hi, > > How can I resize a vector (in STL) and initialize "all" the nodes with > > a particular value? > > > > Thanks and regards, > > Lloyd > > > > ______________________________________ Scanned and protected by Email scanner |