C - memset segfault for statically allocated char array
- by user1327031
I get a segfault when trying to memset an array of chars that was allocated statically, but not for an array of the same length that was allocated using malloc.
variable definitions:
//static
char inBuff[IN_BUFF_LEN];
//dynamic
char * inBuffD;
function call:
//static, cast used because char** != char (*) [n]
serverInit(portNum, (char**) &inBuff, &serv_addr, &sockfd)
//dynamic
serverInit(portNum, &inBuffD, &serv_addr, &sockfd)
use within the function:
memset(*inBuffAdr, 0, IN_BUFF_LEN);
I suspect that my problem is in the difference of the function calls, or to be more precise, my incomplete understanding of the "char** != char (*) [n]" situation. But I have been banging at this for too long and can't see the forest from the trees so any hints and advice would be very appreciated.