malloc的使用、用malloc动态分配内存以适应用户的需求的源代码实例

int len;
   int i = 0;
   printf("please enter the size that you want: ");
   scanf("%d", &len);
   int *pArr = (int*)malloc(sizeof(int) * len);
   printf("please cin the elements:
");
   for(i = 0; i < len; i++)
   {
      scanf("%d", &pArr[i]);
   }

   for(i = 0; i < len; i++)
   {
      printf("%d ", pArr[i]);
   }

   printf("
");
原文地址:https://www.cnblogs.com/hi3254014978/p/9459229.html