Re: [algogeeks] array constant

2011-07-30 Thread prashant bhutani
If a compiler is compiling the code, simply means the compiler is intelligent enough to know what you want to do. But the language specifications, clearly explains not to do such things as these are non-portable!! Thanks & Regards, Prashant Bhutani Senior Undergraduate Computer Science & Engineeri

Re: [algogeeks] array constant

2011-07-30 Thread prashant bhutani
If the value can change then do the memory initialization at run-time using malloc/calloc. The line 5 is giving error because the declaration of an array (and so the allocation of memory) happens at compile time, while the initialization of the variables happen when the program is loaded for the ex

Re: [algogeeks] array constant

2011-07-30 Thread saurabh singh
yeah u can do any non executable statement before you declare the array.remove clrscr statement everything will be fine http://www.ideone.com/SpKpQ On Sat, Jul 30, 2011 at 1:16 PM, Bhanu Pratap Singh wrote: > In GCC, its okay!! > > > -- > You received this message because you are subscribed

Re: [algogeeks] array constant

2011-07-30 Thread Bhanu Pratap Singh
In GCC, its okay!! -- 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. For more options, visit

Re: [algogeeks] array constant

2011-07-30 Thread sukhmeet singh
just adding to the concept.. this is not allowed since value of max may change during the program .. either by declaring it as a macro or as a const we (as said by ankur and varun ) restrict that the value from changing during the program ..!! On Sat, Jul 30, 2011 at 1:09 PM, Ankur Khurana wrote:

Re: [algogeeks] array constant

2011-07-30 Thread Ankur Khurana
or const int max=5; On Sat, Jul 30, 2011 at 1:09 PM, varun pahwa wrote: > make max as a macro. as for c static memory allocation take place either > with a constant or a macro. > i.e. > either u declare > #define max 5 > then write float arr[max]; > > or u may write > > float arr[5]; > > > > > On

Re: [algogeeks] array constant

2011-07-30 Thread varun pahwa
make max as a macro. as for c static memory allocation take place either with a constant or a macro. i.e. either u declare #define max 5 then write float arr[max]; or u may write float arr[5]; On Sat, Jul 30, 2011 at 1:05 PM, Arshad Alam wrote: > Why it is showing an error at line number 5 >