strcat()和strcpy()区别

分类: C_plus_plus |
charbuf[30]={“hello world!”}
chartemp[]={“gold”};
(1)若strcpy(buf, temp);//输出buf结果为gold
(2)若strcat(buf, temp);//输出buf结果为helloworld!gold
(3)若char *ptr=buf+1; //输出ptr结果为elloworld!
前两种情况很简单,下面说明第三种:
buf[30]
strcpy(ptr, temp);
strcat(ptr, temp);
后一篇:latex转义字符