简体   繁体   中英

EXC_BAD_ACCESS with memset

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM