3 ms·
The standard C functions are enough of a mess mentally for me that I try to use them only for simple things. If I'm dealing with lots of string manipulations I
by godshatter 3y ago
The standard C functions are enough of a mess mentally for me that I try to use them only for simple things.
If I'm dealing with lots of string manipulations I usually create a struct with a count and an alloc size and a char* pointer and write init, cleanup, extend, and append functions specific for it and use that as a string type. It's less of a mental load for me to deal with reallocating an array and keeping count and alloc updated correctly once than it is knowing that character arrays are being recounted all the time and worrying about exactly where the '\0' is going to end up and if my buffer is large enough for every string I'm dealing with.