Const in C function declaration and implementation

Viewed 2115

I have a function declared in code.h and implemented in code.c. it goes like:

void someFunc(const char*);

and

#include "code.h"
void someFunc(const char* str){ printf("%s\n", str); }

Now I found out I can remove the const in any one of the files (leaving it there in the other) and it compiles & runs with no errors. I wonder what's the meaning of this? Is one of the files the only one that matters?

It might sound like just an unimportant niche behaviour, but this fact means that a missed const can go unnoticed.

2 Answers
Related