I like the cheating idea better. Since the requirements, as far as I can tell, only seems to be interested in the final output, it is simple enough to run through the string, find the space, change that to a null, print what follows it, then print the first part. I would post what I was playing around with, but it is not interesting, and might be tempting for the OP.