Im writing a funtion that takes string as a argument and gives back a integer. This function counts lenght of a string entered at the command line argument. I get an error :" incompatible pointer types passing 'string' (aka 'char *') to parameter of type 'string *' (aka 'char **') ". Could You help me on this.
My code:
// function declaration
int lenght_of_string( string argv[]);
int main (int argc, string argv[])
{
// function call
int z = lenght_of_string(argv[1]);
printf("Lenght of agrv[1]: %i\n", z);
}
// definition of the function
int lenght_of_string(string argv[])
{
int a = 0;
for (int i = 0; argv[1][i]!='\0';i++)
{
a = i;
}
return a - 1;
}