This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange memory allocation int a[atoi(argv[1])] ?!


Hello!

I've just heard that teachers from one of the university of technology say
that:

int a[atoi(argv[1])];

is correct way to dynamic allocation... what is more it looks like x =
a[999999]; works! o_O
but I run memusage test-prog 1000000 and it doesn't call *alloc nor free at
all, but works well...

in the other hand 
int a[32];
doesn't allow to acces its 1000000 element (it's ok of course)

I wanted to know what gcc does with atoi(argv[2])? Does it only OS allocate
so huge heap so it works?

Or do they wrong?

--
chmi
-- 
View this message in context: http://www.nabble.com/Strange-memory-allocation-int-a-atoi%28argv-1-%29---%21-tf3902478.html#a11063582
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]