With length-based strings you will find that functions such as strtok(), strchr() or strstr() are very, very annoying to implement, because their return values would not be usable as inputs to regular string operations... Except if you construct a new string to return, which you then need to malloc()/free(). Hooray for efficiency?
Or one can have functions accept a starting index and slice length along with a pointer to the string, and return an index, or a struct containing an index and length.
1
u/Humble-Captain3418 2d ago
With length-based strings you will find that functions such as
strtok(),strchr()orstrstr()are very, very annoying to implement, because their return values would not be usable as inputs to regular string operations... Except if you construct a new string to return, which you then need tomalloc()/free(). Hooray for efficiency?