How can I set an array's size at run time?

Answer Posted / shalabh

This can be done by using malloc...if u have an integer
array then ...you can ask user the size..and then allocate
memory for integers...at the run time...using malloc()

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

631


What is the use of static variable in c?

587


Can you please explain the difference between exit() and _exit() function?

582


What is the difference between array and linked list in c?

590


How can I do graphics in c?

586






What is an array? What the different types of arrays in c?

648


why return type of main is not necessary in linux

1694


Difference between constant pointer and pointer to a constant.

603


Explain 'bus error'?

545


What are local static variables?

609


How can I ensure that integer arithmetic doesnt overflow?

596


What is difference between structure and union?

588


explain how do you use macro?

656


Explain logical errors? Compare with syntax errors.

618


Why do we use stdio h and conio h?

625