这句话,sprintf做了什么?

pan2009 2003-10-20 09:07:57
sprintf(m_toHost->messageStr+strlen(m_toHost->messageStr),
"%s%s",'\n', theValue);

这句话,sprintf做了什么?
...全文
74 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
smokefire 2003-10-20
  • 打赏
  • 举报
回复
char str[1024];
sprintf(str,"%s%s","hello ","world!");
printf("%s\n",str);

将输出hello world!

还有很多%s是字符串,%d是int 等等 类似于printf
jEditor 2003-10-20
  • 打赏
  • 举报
回复
相当于:
m_toHost->messageStr+strlen(m_toHost->messageStr +'n' + theValue;
形成一条字符串..
sprintf在这里是写值作用,%s是写入字符.

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧