I have a block of code where I try to grab an expression inside parentheses and then use it. At the moment when the code below starts, I'm in the middle of iteration through an array of characters, and pcc- a pointer to the current character, which was defined as '('. My goal is to put a parathetic expression into an array of characters pe.
int nnrp = 1;
char * pbpe = pcc;
for (++pcc; *pcc!= '\0' && nnrp != 0; ++pcc)
{
if (*pcc == '(')
{
++nnrp;
}
else if (*pcc == ')')
{
--nnrp;
}
else if (*pcc == '\0')
{
sprintf(err, "Unbalanced paranthesis");
return -1;
}
}
long nel = pcc - pbpe;
if (nel == 1)
{
sprintf(err, "Empty parenthesis");
return -1;
}
char * pe = (char*)malloc(nel+1);
strncpy(pcc+1, pcc, nel);
pe[nel] = '\0';
But my IDE (Xcode 6.0) gives me a warning
"Semantic problem: implicitly declares a library function 'malloc' of type 'void * (unsigned long)'"
in line strncpy(pcc+1, pcc, nel);. I'm interested
- why am I getting this warning.
- Do I need to fix it.
- - , .
.