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 <[email protected]>wrote: > or const int max=5; > > > On Sat, Jul 30, 2011 at 1:09 PM, varun pahwa <[email protected]>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 Sat, Jul 30, 2011 at 1:05 PM, Arshad Alam <[email protected]> wrote: >> >>> Why it is showing an error at line number 5 >>> >>> >>> 1. void main() >>> 2. { >>> 3. clrscr(); >>> 4. int i,max=5; >>> 5. float arr[max]; >>> 6. for(i=0;i<max;i++) >>> 7. scanf("%f",&arr[i]); >>> 8. getch(); >>> 9. } >>> >>> -- >>> 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. >>> >> >> >> >> -- >> Varun Pahwa >> B.Tech (IT) >> 7th Sem. >> Indian Institute of Information Technology Allahabad. >> Ph : 09793899112 >> Official Email :: [email protected] >> Another Email :: [email protected] >> >> People who fail to plan are those who plan to fail. >> >> -- >> 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. >> > > > > -- > Ankur Khurana > Computer Science > Netaji Subhas Institute Of Technology > Delhi. > > -- > 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.
