knowledge:数组的传递及返回
Demo:
#include <stdio.h>
#include <stdlib.h>
int* func(int a[],int b[]){
int* s;
s = malloc(sizeof(int)*5);
s[0] = a[0];
s[1] = a[1];
s[2] = a[2];
s[3] = b[0];
s[4] = b[1];
return s;
}
int main()
{
int i = 0 ;
int a[3] = {1,2,3};
int b[2] = {4,5};
int* s = func(a,b);
for(i = 0 ; i < 5 ; i ++){
printf("%d ",s[i]);
}
free(s);
return 0;
}
Output:
1 2 3 4 5