int main()
{
char word[100];
char* lowerCase;
scanf("%s", word);
lowerCase = toLowerCase(&word);
printf("%s", lowerCase);
}
char * toLowerCase(char *str)
{
int i;
for(i = 0; str[i] != '\0'; ++i)
{
if((str[i] >= 'A') && (str[i] <= 'Z'))
{
str[i] = str[i] + 32;
}
}
return str;
}
I am getting a warning while executing the above code. the warning is
try.c: In function 'main':
try.c:16:26: warning: passing argument 1 of 'toLowerCase' from incompatible pointer type [-Wincompatible-pointer-types]
lowerCase = toLowerCase(&word);
^~~~~
try.c:4:7: note: expected 'char *' but argument is of type 'char (*)[100]'
char* toLowerCase(char *str);
I am not able to understand why this warning is coming? if i am passing (word) to the function there is no warning, but when i execute the following code the output is same:
printf("%d", word);
printf("%d", &word);
If the address is same then why this warning?