- ..clause 1..: The method is not understood though I want to declare a dynamic array by using malloc.
First of all, malloc is not necessary in the program that the beginner makes.
[ How to use of easiest malloc ]If it is a very small-scale program, it should not be liberating according to the free function.
Secure the memory as follows. It is the same also excluding the int type. Even the structure.
int *data;
Data = Malloc (Sizeof(int) necessary number of elements of *);
The secured memory can be used by doing just like a usual array.
data[i] = 10;
Increase it as follows when coming to want to increase the number of elements.
Data = Realloc (Data and sizeof(int) necessary number of elements of *);
Thus, liberate it when you do not use the array.
free(p);