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

Answer Posted / vinod

C99 and above supports the conceptof VLA(Variable Length Array) which allows you to set array size based on input during run time. It can also done using dynamic memory allocation.

Example:
int main()
{
int i;
scanf("%d",&i);
int a[i];
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is return a keyword in c?

835


What is the purpose of clrscr () printf () and getch ()?

796


How can I run c program?

939


how many errors in c explain deply

1837


What is the difference between the local variable and global variable in c?

731


What is c preprocessor mean?

1038


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

4102


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1244


What does void main return?

842


Is c still used?

802


Explain how do you convert strings to numbers in c?

833


Which is the memory area not included in C program? give the reason

1726


What are the different data types in C?

949


What is a macro, and explain how do you use it?

825


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

824