`
wss71104307
  • 浏览: 218648 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

自己写strcat函数,有点小问题

阅读更多

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.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics