< [modosusu] > Color magazine monochrome light and shade font predetermined, Gothic Ming-style type longhand size Konaka large standard
I want to use dynamic array &malloc.
- ..clause 1..: The method is not understood though I want to declare a dynamic array by using malloc.
 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.
The personal computer nowadays is char s;Do not make it to [biku] in the array of the level.
Moreover, it is necessary to refrain from malloc oppositely for building in for the memory saving.
Read the following usage after basing that.
[ 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.
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.
However, because the possibility that the teacher and the superior are angry that free is not put up is high
Call the free function at the end of the main function.
It returns to contents.
< - Advanced -> to the returning following. the first that returns