How to concatenate string and int in C?

Strings are hard work in C. The 12 is enough bytes to store the text “pre_”, the text “_suff”, a string of up to two characters (“99”) and the NULL terminator that goes on the end of C string buffers. This will tell you how to use snprintf, but I suggest a good C book!

Implementation of strtok() function

Internal implementation of strtok has already been discussed here: How does strtok() split the string into tokens in C? In your type of implementation ( calling it your type because it is quite different from the actual one), you have not allocated any memory dynamically to the local variable ‘W’. So when you return it, … Read more