C语言中函数返回数组
2020-11-22 18:31
标签:int set har for amp c语言 main print size char return #include "stdio.h" C语言中函数返回数组,搜素材,soscw.com C语言中函数返回数组 标签:int set har for amp c语言 main print size char return 原文地址:http://www.cnblogs.com/luxiaolai/p/3701023.html
/*
int* set(int a,int *c)
{
int
*b;
b=malloc(sizeof(int)*3);
c[0]=a;
c[1]=1+a;
c[2]=2+a;
b[0]=13;
b[1]=14;
b[2]=15;
return
b;
}
*/
char *set(void)
{
char
*buf;
buf=malloc(sizeof(char)*3);//创建内存区
buf[0]=0x30;
buf[1]=0x31;
buf[2]=0x32;
return
buf;
}
void main(void)
{
/*
int b[3];
int
*c;
int i;
// c=malloc(sizeof(int)*3);
c=set(3,&b);
for(i=0;i printf("b=%d\n",b[i]);
for(i=0;i printf("a=%d\n",c[i]);
free(c);
*/
char
*c;
int
i;
c=set();
for(i=0;i printf("c=%c\n",c[i]);
free(c);//释放内存区
}