The behaviour of allowing the following code to compile:
cin >> x;
int a[x];
by gcc/g++ is due to historical reasons. This kind of a declaration is
called a variable length array however it is not supported by the C++ and C
standards.
To prove that this is the case, recompile with
g++ -pedant
Its from stack. Using int a[n] the amount of memory that can be allocated is
very small as compared to that in case of using malloc( heap allocation ).
On Wed, Jun 15, 2011 at 2:45 PM, sunny agrawal wrote:
> @kartik sachan
> This function is *not* defined in ANSI-C and is *not* part of C++, but i
@kartik sachan
This function is *not* defined in ANSI-C and is *not* part of C++, but is
supported by some compilers.
and +1 to Shachindra's post...i also think memory allocation will be
from heap...not stack
On Wed, Jun 15, 2011 at 2:34 PM, Shachindra A C wrote:
> @vipul : dynamic memory al
@vipul : dynamic memory allocation from stack? are you sure? generally
dynamic memory allocations are done from the heap right?
On Wed, Jun 15, 2011 at 2:28 PM, kartik sachan wrote:
> hey is itoa() is supported by g++ compliers???
>
> --
> You received this message because you are subscribed to
hey is itoa() is supported by g++ compliers???
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.
Its not a standard, it is one of the gcc extension i.e variable length
arrays. Memory allocation is done dynamically from stack in such case.
On Tue, Jun 14, 2011 at 8:27 PM, kartik sachan wrote:
> it is correct ...in c++ 4.3.2 compiler
>
> --
> You received this message because you are subs
it is correct ...in c++ 4.3.2 compiler
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
but such a declaration is working correctly in g++
On Tue, Jun 14, 2011 at 8:22 PM, Don 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 *)