加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

strcat()和strcpy()区别

(2018-12-20 19:30:05)
分类: C_plus_plus

charbuf[30]={“hello world!”}

chartemp[]={“gold”};

1)若strcpy(buf, temp);//输出buf结果为gold

2)若strcat(buf, temp);//输出buf结果为helloworld!gold

3char *ptr=buf+1; //输出ptr结果elloworld!

           strcpy(ptr, temp);//输出ptrgold,输出buf则为hgold,输出buf+6world!说明插入temp的时候,加入’\0’buf

           strcat(ptr, temp);//输出ptrgoldgold,输出buf则为hgoldgold,输出buf+10则为d!

前两种情况很简单,下面说明第三种

buf[30]

strcat()和strcpy()区别


strcpy(ptr, temp);

strcat()和strcpy()区别


strcat(ptr, temp);

strcat()和strcpy()区别

0

阅读 收藏 喜欢 打印举报/Report
后一篇:latex转义字符
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有