How can i declare an array without initializing its size? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Resposta
+ 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