そのため、K&R を使用してポインター付きの C コードを書く練習をしていました。strcat関数の1 つの問題については、自分のコードの何が問題なのかを見つけることができませんでした。Visual Studio によると、strcat 関数の後に目的の文字列が変更されずに返されました。どんな提案でも大歓迎です!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int strcat(char* s, char* t);
int main(void)
{
char *s="hello ", *t="world";
strcat(s,t);
printf("%s",s);
return 0;
}
int strcat(char* s,char* t)
{
int i;
i=strlen(s)+strlen(t);
s=(char*) malloc(i);
while(*s!='\0')
s++;
while('\0'!=(*s++=*t++))
;
return 0;
}