I need to write a program, that lists keystrings for each command for a given set of commands.
Input
The first line contains the number n of commands for the console application.
Each of the following n lines contains one command of the client.
Each command is a nonempty string consisting of lowercase Latin letters and its length is at most 100.
No command is a proper substring of another command.
Output
Output n lines.
The i-th line should contain any of the shortest key substrings of the i-th command (the commands are numbered in the order they are given in the input).
Sample
input output
3
abcm ab
acm ac
bcd d
abd abd
I first need to know how to split a string like "abcd" into a b c d separately. I can't use strtok() because it take a delimiter like space, comma or hyphen etc. I can't use delimiters within the same word. Please help me out.
Thanks,
Kahaly