请问此c程序哪里出错了。。谢谢

要求将输入的两个字符串连接起来。
#include
#include
char s1[80],s2[80];
int main()
{ void f();
printf("say sth:");
gets(s1);
printf("say sth. again:");
gets(s2);
f();
}
void f()
{ int i;
strcat(s1,s2);
for(i=0;i<=80;i++)
printf("%c",s1[i]);
}

 #include <stdio.h>

char s1[80],s2[80];

void f(char *a, char * b)
{
    char * a1 = a;
    while (*a1 != '\0') a1++;
    for (char * b1 = b; *b1 != '\0'; b1++,a1++)
    {
        *a1 = *b1;
    }
    *a1 = '\0';
}

int main()
{  
  printf("say sth:");
  gets(s1);
  printf("say sth. again:");
  gets(s2);
  f(s1,s2);
  printf("%s",s1);
  return 0;
}

say sth:hello
say sth. again: world
hello worldPress any key to continue

这个程序没有错,只是可能不符合要求,因为你只是简单调用了strcat

此段程序 ,可能出现的错误是内存越界
如果 s1 与 s2 的长度和大于 80,这样按上述代码操作, s1 无法存贮下合并后的字符串而导致内存越界。