reading the book of 《the C programing language》,write a program by myself about strcat ,but here is a mistake. I recode the program here in order to find the causation in future.
#include <stdio.h> void myStrcat(char s[],char t[]) { int i=0,j=0; while(s[i] != '\0') i++; while((s[i++]=t[j++]) != '\0'); } int main() { char s[]="abde"; char t[]="word!"; myStrcat(s,t); printf("%s\n",s); }
I guess the problem is the memory of allocation.