带memset的EXC

编程入门 行业动态 更新时间:2024-10-28 14:25:29
memset的EXC_BAD_ACCESS(EXC_BAD_ACCESS with memset)

获取错误Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

unsigned char *nkey; memset(nkey, 0x00, 256); // error is here

我用sprintf设置nkey然后我用它作为参数。

没有编译时错误,但运行时会显示错误。 我正在使用Xcode。

Getting error Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

unsigned char *nkey; memset(nkey, 0x00, 256); // error is here

I am setting nkey with a sprintf then after I use it as a parameter.

There are no compile time errors, but when running it shows that. I am using Xcode.

最满意答案

例如,您首先需要为nkey分配内存

unsigned char *nkey = new unsigned char[256]; // block of 256 uchars

You first need to allocate memory for nkey, for example

unsigned char *nkey = new unsigned char[256]; // block of 256 uchars

更多推荐

本文发布于:2023-08-06 18:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:memset   EXC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!