December 21, 2011

Converting a space delimited sentence into a sequence of null terminated strings

The title says it all, you are given a string which consists of words separated by spaces, here is a snippet of code for converting the same into a sequence of null terminated strings and then later printing them. Returning the indices in the original string where the words begin is the key here :




Printing the strings is pretty trivial as :




Quick code, picked up the hack from a certain shell command parsing code in Xinu.