Click here to Skip to main content
15,896,915 members

Response to: how to remove the duplicate words in C

Revision 2
You didn't specify if you need to suppress all duplicate words or just the consecutive duplicate words.

Assuming the latter option, you need to split the path to get the words between the slashes. You can do this with strtok, but scanning the string yourself is not much harder: search for a backslash and if you find one, continue the search for the next non-backslash character.

When you search a new word, make sure to keep a trace of the previous you found. Then compare both. Copy the words and backslashes as you go, except in the case of a duplicate.
Posted 3-Nov-12 12:48pm by YvesDaoust.
Tags: , ,