News for hackers. Stuff that matters.
Re:Tell HN: C Experts Panel – Ask us anything about C by _kst_ on Tuesday April 14, 2020 @05:39PM (#22871807)
strchr() is one of several C library functions that have this issue.

C++ solved this by overloading strchr():

    const char *strchr(const char *s, int c);
    char *strchr(*char *s, int c);
C of course doesn't have overloading.

One solution could have been to define two functions with different names, perhaps "strchr" and "strcchr". The time to do that would have been 1989, when the original ANSI C standard was published.

I suppose a future C standard could leave strchr() as it is (necessary to avoid breaking existing code) and add two new functions.

There are no comments on this comment yet.