Use code tags (see the red text on your editor?).
And by the way, you're not done yet. Where's the function?
To implement it as a function, is not the trouble
it's not a problem to write
void foo(char *str)
My problem was just to implement the concept
Thank you, my friend