Ad
  • Custom User Avatar

    True, it would be safer and good practice to return pointer to const.
    On the other hand, I would never assume any char pointer returned by some function safe for changing unless this is clearly documented for this function. This is C, if you want to make problems you can even cast const to non-const.

  • Custom User Avatar

    Dangerous: "hello world!" is returned as a constant, which can reside in read-only memory. If the caller tried to modify the string -- which should be legal for non-"const" pointers -- it could crash.

  • Default User Avatar

    Why do I have to set a pointer before greet?