C/Incompatible type warning
Expert: Joydeep Bhattacharya - 5/14/2007
Question void foo(const char **p) { }
int main(int argc, char **argv)
{
foo(argv);
return 0;
}.
I am getting a warning message as incompatible type in foo()
Can you explain clearly why i am getting that warning...?
When we say the types are compatible..?
I will be thankful for your reply...
AnswerHi Ravi
There seems to be no problem with your code but still I have tested this code with Turbo C and its working perfectly.
#include<stdio.h>
void foo(const char **p) { printf("\n%s",*p); }
int main(int argc, char **argv)
{
int i;
printf("\n%d",argc);
for(i=0;i<argc;i++)
foo(argv+i);
return 0;
}
Will you please tell me in which compiler you are getting this error message.
Generally a type compatible warning occurs when the type of the parameter mismatches but the compiler will be able to to assign value with some data or precision loss.
Please feel free to revert back to me in case of any doubt !
regards
Joydeep