Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to write a dynamic integer array with C, the length is the number of input integer elements?
How to write a dynamic integer array with C, the length is the number of input integer elements?
Use malloc function to dynamically allocate memory:

# include & ltstdio.h & gt

# include & ltmalloc.h & gt

int main()

{

int num

scanf("%d ",& ampnum);

int * arr =(int *)malloc(sizeof(int)* num);

......

Returns 0;

}