Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > array of variable length

Reply
Thread Tools

array of variable length

 
 
Huub
Guest
Posts: n/a
 
      05-08-2011
Hi,

I want to create an array, but it's length be specified by console input.
Is this possible?

Thanks

 
Reply With Quote
 
 
 
 
Marc
Guest
Posts: n/a
 
      05-08-2011
Huub wrote:

> I want to create an array, but it's length be specified by console input.
> Is this possible?


If you mean:
int tab[variable];
or
std::array<int,variable> tab;

---> no.

If you mean:
int* tab=new int[variable];
or
std::vector<int> tab(variable);

---> yes.
 
Reply With Quote
 
 
 
 
Huub
Guest
Posts: n/a
 
      05-08-2011
On Sun, 08 May 2011 12:53:00 +0000, Marc wrote:

> Huub wrote:
>
>> I want to create an array, but it's length be specified by console
>> input. Is this possible?

>
> If you mean:
> int tab[variable];
> or
> std::array<int,variable> tab;
>
> ---> no.
>
> If you mean:
> int* tab=new int[variable];
> or
> std::vector<int> tab(variable);
>
> ---> yes.


Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Flexible array member + variable length array Adam Warner C Programming 10 02-10-2005 10:11 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
What will happen when the size of a local variable length array turns out to be 0 (zero)? Xiangliang Meng C++ 18 06-11-2004 02:55 AM
Re: variable length array Dan Pop C Programming 24 06-26-2003 07:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57