#include <iostream> #include<stdio.h> int* removeDuplicates(int numsSize) { // malloc是常用的动态内存分配 int* arr = (int*)malloc(numsSize * sizeof(int)); return arr; } int main() { int numsSize = 10; int* arr; arr = removeDuplicates(numsSize); for (int i = 0; i < numsSize; i++) { arr[i] = i+2; } for (int i = 0; i < numsSize; i++) { printf("%d\n", arr[i]); } return 0; }
标签:numsSize,arr,return,int,malloc,C语言,动态内存,分配 From: https://www.cnblogs.com/shunguo/p/17727200.html