如何将字符复制到字符数组
我有:
char frame[4][8];
char szBuff[8] = "";
并且我想做这样的事情:
frame[i][j] = szBuff[0];
但它不起作用:
Access violation reading location 0xcccccccc.
I have:
char frame[4][8];
char szBuff[8] = "";
and I want do something like this:
frame[i][j] = szBuff[0];
but it doesnt work:
Access violation reading location 0xcccccccc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有几种方法可以完成(我认为)您想要做的事情。以下是三个:
There are several ways to accomplish what (I presume) you are trying to do. Here are three:
您很可能正在读取数组范围之外的内容。调试它并确保 i 和 j 不会在您声明的数组范围之外递增。确保:
i < 4 且 i >= 0
j< 8 且 j >= 0
You are reading outside the bounds of your array more than likely. Debug through it and make sure i and j aren't being incremented outside the bounds of the array you declared. Make sure:
i < 4 and i >= 0
j < 8 and j >= 0
确保你的 i 和 j 没有超出数组...
示例:
不会工作;
这段代码:
工作正常。
Be sure that your i and j are not out of array...
Example:
Will not work;
This code:
Works fine.