带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 hereI 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 ucharsYou first need to allocate memory for nkey, for example
unsigned char *nkey = new unsigned char[256]; // block of 256 uchars更多推荐
发布评论