Reputation: 313
I'm getting this error that says "Conflicting type for method compress
"
Here is my code:
int main(int argc, char **argv){
char* ptr = argv[1];
printf("%c\n", compress(ptr, 'j', 1));
}
const char* compress(char* ptr, char c, int i){
return "Hi";
}
Does anyone know what the issue is? Thanks so much for your help!
Upvotes: 1
Views: 178
Reputation: 223739
You attempted to use compress
before it was declared. As a result, the default function declaration of int compress()
was assumed. That implicit declaration doesn't match the actual definition.
Move compress
above main
. That way the function is defined before it is used.
Also, in your call to printf
, you use the %c
format specifier which expects a char
but you pass in a char *
. Change the format specifier to %s
to match so that the entire string is printed.
Upvotes: 3