Getting "conflicting types for function" in C, why?

arrays, c

Solution

You are trying to call do_something before you declare it. You need to add a function prototype before your printf line:

char* do_something(char*, const char*);

Or you need to move the function definition above the printf line. You can't use a function before it is declared.

Problem

I'm using the below code: ``` char dest[5]; char src[5] = "test"; printf("String: %s\n", do_something(dest, src)); char *do_something(char *dest, const char *src) { return dest; } ``` The implementation of `do_something` is not important here. When I try to compile the above I get these two exception: error: conflicting types for 'do_something' (at the printf call) error: previous implicit declaration of 'do_something' was here (at the prototype line) Why?

Original source