[algogeeks] Re: is it correct??

2011-06-16 Thread KK
Use sprintf(string, formatSpecifier, variable) instead u can even use %o %x for changing integer to corresponding oct and hex... -- 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.

Re: [algogeeks] Re: is it correct??

2011-06-15 Thread DK
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

Re: [algogeeks] Re: is it correct??

2011-06-15 Thread • » νιρυℓ « •
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

Re: [algogeeks] Re: is it correct??

2011-06-15 Thread sunny agrawal
@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

Re: [algogeeks] Re: is it correct??

2011-06-15 Thread Shachindra A C
@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

Re: [algogeeks] Re: is it correct??

2011-06-15 Thread kartik sachan
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.

Re: [algogeeks] Re: is it correct??

2011-06-14 Thread • » νιρυℓ « •
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

Re: [algogeeks] Re: is it correct??

2011-06-14 Thread kartik sachan
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.

Re: [algogeeks] Re: is it correct??

2011-06-14 Thread amit kumar
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 *)

[algogeeks] Re: is it correct??

2011-06-14 Thread Don
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