Click here to Skip to main content
Sign Up to vote bad
good
See more: C++CVisual-Studio
I have a path like this
 
C:\Users\Desktop\new3oct\31oct\Project\Project\\bin\\logsgs"
By programming i have to convert it to this,should i use strtok? Not getting the logic,please tell
 
"C:\Users\Desktop\new3oct\31oct\Project\bin\\logsgs"
Posted 3 Nov '12 - 11:36

Comments
Andrew Cherednik - 3 Nov '12 - 18:20
you have specified many tags: C, C++, Visual Studio. What technology are you planning to use? strtok is C

1 solution

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 369
1 OriginalGriff 190
2 Tadit Dash 168
3 CPallini 163
4 Aarti Meswania 153
0 Sergey Alexandrovich Kryukov 10,169
1 OriginalGriff 7,749
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid