luxiaolai

#include "stdio.h"
/*
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<3;i++)
  printf("b=%d\n",b[i]);
 for(i=0;i<3;i++)
  printf("a=%d\n",c[i]);
 free(c);
 */
 char *c;
 int i;
 c=set();
 for(i=0;i<3;i++)
  printf("c=%c\n",c[i]);
 free(c);//释放内存区 
}

分类:

技术点:

相关文章:

  • 2021-07-21
  • 2021-11-07
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-12
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案