在线求助,c高手帮我分析一下,谢谢了
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
char *func(int num,...);
int main()
{
char *p;
p=(char *)malloc(30);
p = func(3,"a","fdsaf","egggge");
printf("连接以后为 %s ",p);
system("PAUSE");
free(p);
return 0;
}
char *func(int num, ...)
{
va_list arg_ptr;
int i;
char *c;
c = malloc(30);
va_start(arg_ptr,num);
for(i=0;i<num;i++)
{
c=strcat(c,va_arg(arg_ptr,char));
}
va_end(arg_ptr);
return c;
}