练习5-3 用指针方式实现第2章中的函数strcat。函数strcat(s, t)将t指向的字符串复制到s指向的字符串的尾部。
#include <stdio.h>int my_strcat(char *, char *);int main()
{char s[20], t[10];printf("please input string s, while s has no more than 10 chars.\n");scanf("%s", s);printf("please input string t, while t has no more than 10 chars.\n");scanf("%s", t);my_strcat(s, t);printf("concatenated string:%s\n", s);return 1;
}int my_strcat(char *s, char *t)
{//int i = 0, j = 0;while (*s++ != '\0');s--;while ((*s++ = *t++) != '\0');return 1;
}