but such a declaration is working correctly in g++

On Tue, Jun 14, 2011 at 8:22 PM, Don <[email protected]> wrote:

> One line or the other is not correct. The size of an array must be a
> constant, and you can't read into a const.
> If you want to do something like this, use malloc:
>
> cin >> x;
> int *a = (int *)malloc(x*sizeof(int));
>
> You can now use "a" as if it is an array of size x. Be sure to free
> the memory before "a" goes out of scope.
>
> Don
>
> On Jun 14, 9:39 am, amit <[email protected]> wrote:
> > is such a declaration correct:
> > cin>>x;
> > int a[x];
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to