I'd rather not write down the program for you, since you need to learn finding the solution for yourself. And that is more important than knowing the solution.
Instead, I suggest you look up the C string functions, e. g. at
C - Strings and String functions with examples[
^].
You'll find plenty of information on C strings in general, and explanations with examples for each C string function. Probably there is at least one useful example program that you could use as a starting point to solve your task.