dynamic initialization

can sumone give me tell me how can we initialize an array, wherin the size of the array is specified by the user?
vector<int> array(size);
See http://www.cplusplus.com/reference/stl/vector/
closed account (zb0S216C)
In addition to Athar's suggestion, you could use DMA'd arrays if the length is fixed:

1
2
3
4
unsigned char *Array( new unsigned char[4] );

for( unsigned int I( 0U ); I < 4; ++I )
    Array[I] = '...';


If your compiler supports C++11 DMA'd array initialization:

 
unsigned char *Array( new unsigned char[4] { 0 } );


Wazzak
Topic archived. No new replies allowed.