You are here:

C/Incompatible type warning

Advertisement


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...

Answer
Hi 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

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

Ability to solve C and Data Structure problems and puzzles with simple and easy to understand logic.

Experience

C, C++, Java, Data Structure, PHP, Web Designing

Organizations
http://www.scodz.com Designation: webmaster

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Past/Present Clients
http://analysingc.50webs.com http://www.funforu.com

©2012 About.com, a part of The New York Times Company. All rights reserved.