Re:Elevate your C programming skills by exploring the SQLite...
by jjnoakes on Sunday July 09, 2017 @02:25PM
(#14730982)
Sure, if you return an index. I bet the parent poster was discussing returning a pointer, though.
Imagine look4 returned a pointer to the found element. Making look4's signature const-correct in C is not possible.
(Think of strchr).
Re:Elevate your C programming skills by exploring the SQLite...
by jstimpfle on Sunday July 09, 2017 @03:55PM
(#14731352)
As my sibling poster explained, that's not why meant.
Try to reduce some of the problems these people have: https://stackoverflow.com/questions/856542/elegant-solution-...
My friend, your example is wrong! The caller can happily work with a mutable array; the function accepting a "const" pointer is just a guarantee that the function itself* won't modify the content.