I'm trying to learn more about C and I was wondering if anyone could clarify what's going on here. I'm getting a compiler warning: "warning: assignment makes integer from pointer without a cast @ msg[msglen+1] = "\0""
char *msg = NULL;
int len = 10;
int msglen = 0;
while(<argument>) {
msg = (char *)calloc(len, 1);
strncpy(msg, <some string>, len);
msglen = strlen(msg);
msg[msglen+1] = "\0";
Thanks, I appreciate you help!
strncpy(). That's almost certainly not the best solution.msglen = strlen(msg);has potential for undefined behaviour, sincestrncpydoesn't usually 0-terminate.