How can i declare an array without initializing its size? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i declare an array without initializing its size?

Need it for a program to perform set operations in C.

16th Sep 2018, 2:09 PM
Rajat Naskar
Rajat Naskar - avatar
1 Answer
+ 5
int *array; pointers and arrays are equivalent. You need a size variable to keep track of how much you got and a malloc call to allocate the array memory. realloc call can add or remove memory as needed. free call to return all of the memory.
16th Sep 2018, 3:43 PM
John Wells
John Wells - avatar