Proper Way To Initialize Unsigned Char*
问题 What is the proper way to initialize unsigned char* ? I am currently doing this: unsigned char* tempBuffer; tempBuffer = ""; Or should I be using memset(tempBuffer, 0, sizeof(tempBuffer)); ? 回答1: The second method will leave you with a null pointer. Note that you aren't declaring any space for a buffer here, you're declaring a pointer to a buffer that must be created elsewhere. If you initialize it to "" , that will make the pointer point to a static buffer with exactly one byte—the null