String manipulation utility in C