sprintf()格式化字符串的时候,多出一个"-"具体的原因是什么?

zanglengyu 2014-02-19 07:34:23
char name[32];
sprintf(name,"ui/prepare/heroicon%d.png",heroId);
最终的字符串 不是"ui/prepare/heroicon6.png"

儿是"ui/prepare/heroicon-1.png"
...全文
368 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zanglengyu 2014-03-19
  • 打赏
  • 举报
回复
引用 1 楼 jerry_dqh 的回复:
heroId 这个值是-1吧
是的 -1,改了 耳环
赵4老师 2014-02-21
  • 打赏
  • 举报
回复
To set a breakpoint when a variable heroId changes value From the Edit menu, click Breakpoints. Click the Data tab of the Breakpoints dialog box. In the Expression text box, type the name of the variable heroId. Click OK to set the breakpoint.
零度的折翅 2014-02-21
  • 打赏
  • 举报
回复
heroId值可能被改了,改成-1,所以才会输出-1,你单步调试一下。
tuzhutuzhu 2014-02-21
  • 打赏
  • 举报
回复
heroId可能是个返回值之类的,上一次使用被赋值为-1了。单步调试一下就知道了
xiaohuh421 2014-02-21
  • 打赏
  • 举报
回复
你这个32好紧哟, herold 稍大些, 就要越界了, 你就悲剧了.
missheaven2011 2014-02-20
  • 打赏
  • 举报
回复
herold 被改了吧
starytx 2014-02-20
  • 打赏
  • 举报
回复
heroId的类型是int吗?断点跟踪一下heroId的值
loe 2014-02-20
  • 打赏
  • 举报
回复
herold 值为 -1
  • 打赏
  • 举报
回复
看看heroId的值在哪里做了修改,导致不符合你的预期。
碼上道 2014-02-19
  • 打赏
  • 举报
回复
heroId 这个值是-1吧

69,373

社区成员

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

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