C compare string literal with function returning char pointer -


why code:

strcmp(myfunction(0), "ok"); 

where myfunction defined this:

char *myfunction(int p) {     if (p == 0)     {         return("ok");     } } 

give following error:

warning: passing argument 1 of 'strcmp' makes pointer integer without cast 

do have prototype above call? function should either prototyped or defined before used. otherwise compiler assume has default return type of int.

// prototype char *myfunction(int p);  int main() {     // use     strcmp(myfunction(0), "ok"); }  // definition char *myfunction(int p) {     ... } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -