c - getting an error about char* in using strcmp(char*,char*) -


i'm getting error:

$ gcc -wall -g translate.c support.c scanner.c -o translate support.c: in function ‘translate’: support.c:148:13: warning: passing argument 1 of ‘strcmp’ incompatible pointer type     [enabled default]              comparenum = strcmp(dict[i], token);              ^ in file included /usr/include/stdio.h:29:0,                  support.c:1: /usr/include/string.h:28:6: note: expected ‘const char *’ argument of type ‘char **’  int  _exfun(strcmp,(const char *, const char *));   ^ 

and here function translate()

int translate(char* token, char** dict[], int dictlength) {     int = 0;     int comparenum;      for(i=0;i<dictlength;i++)     {         if(i % 2 == 0)         {             comparenum = strcmp(dict[i], token);             ++i;             if(comparenum == 1)             {                 return i;             }         }     }  return 0;  } 

for reason i'm passing in dict[i], array of strings i'm trying compare each element of array string token saying char**. know array char** wouldn't element char *?

the dict argument declared so:

char** dict[] 

so dict[i] of type char**. hence error.

i guess in order offer further advice we'd need have details of object supply dict argument when calling function. perhaps need change declaration of argument be:

char* dict[] 

one thing recommend use const when declaring these parameters, allow pass non-modifiable strings.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -