Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to store a large number with an array?
How to store a large number with an array?
Storing large numbers with arrays can be realized by malloc function. The specific code is as follows:

int n;

scanf("%d ",& ampn);

int * a =(int *)malloc(n * sizeof(int));

The parameter of malloc is the size of allocated space, and n*sizeof(int) represents the allocation of n integer spaces. Because the first address returned by malloc is void, it is cast to int.

Malloc is used for dynamic allocation and can be allocated when needed. In practical application, it can be converted into the type you need according to your needs.