News for hackers. Stuff that matters.
Re:Str: Yet another string library for C language by abqexpert on Wednesday November 25, 2020 @05:29PM (#25215002)
If you wanted to slice at an arbitrary point, then you would either have to lose some data in the original string, move or copy the original string to make space for the extra delimiter/null character, or have set up the string ahead of time to contain the delimiter in the desired position. If you are using strtok.
Re:Str: Yet another string library for C language by souprock on Thursday November 26, 2020 @12:28AM (#25217144)
There is also the mangle-use-repair choice. I've done that with pathnames for creating nested directories.

C programmers are expected to make the best choice based on the situation. The various choices trade off memory usage, CPU usage, source code readability, and program correctness.

Re:Str: Yet another string library for C language by account42 on Thursday November 26, 2020 @07:45AM (#25219522)
> There is also the mangle-use-repair choice.

Which is problematic for thread safety and depending on the source of the string (constant) may not be possible.

Re:Str: Yet another string library for C language by souprock on Friday November 27, 2020 @06:31PM (#25233539)
It's not problematic. C programmers are expected to avoid screwing that up. C is a full-power language.

If available, strdupa() would be a fine way to get a suitable local copy of the string. Commonly though, the programmer knows that there will not be threads and can make the string non-constant.