Can anyone explain this error? Here is my code:

int main(int argc, string argv[])
// code snipped

int c = strlen(argv);

// code snipped

Here is the error:

vig.c:15:20: error: incompatible pointer types passing 'string *' (aka 'char **') to parameter of type 'const char *'; dereference with * [-Werror,-Wincompatible-pointer-types]
int c = strlen(argv);
/usr/include/string.h:399:35: note: passing argument to parameter '__s' here
extern size_t strlen (const char *__s)

Thanks in advance!

1 Answer 1


int c = strlen(argv); strlen(a_string) takes a string as an argument. You have used argv as an argument, an array of strings. If you wanted to get the length of a particular string in the array, for instance, the first parameter of the program invocation, you would use int c = strlen(argv[1]);

Anticipating another issue, here's another example. If you wanted to access the fifth character in the second parameter (which is a string), you would use argv[2][4].

If this answers your question, please accept this answer to close the question. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .