strncpy causing warning and segfault

So I am getting an error that says:
"passing arg1 of 'strncpy' makes pointer from integer without a cast"

Here is the fragment of code causing the problem could someone please suggest what is going on:
while (pch!=NULL){
pch=strtok(NULL," ");
if (pch !=NULL && pch!= "="){
int index=0;

strncpy(formalParameters[index],pch, MAX_NAME);
index++;
}
}


...where pch is a char array declared as:
char pch[MAX_FORMALPARAMETER+1];
memset (pch,0,MAX_FORMALPARAMETER);


and formalParameters is also declared and memset like pch

If I 'make' my program I get that warning. If I run it with an input file I get a 'segfault' that with the use of 'ddd' debugger points me to this 'strncpy'..any idea's anyone?
thanks
Abhi


strncpy(formalParameters[index],pch, MAX_NAME);


how you have declared ...
formalParameters


because parameter 1, i.e. formalParameters[index] looks strange. what i mean is , it should be passed as
strncpy(formalParameters,pch, MAX_NAME);
if its not a double dimensional array.

Yes, OP said formalParameters is a char array. The compiler warning is tell OP what the bug is: OP needs &formalParameters[index].
Yup that was it. Thanks guys I was getting confused.
Topic archived. No new replies allowed.