Click here to Skip to main content
11,711,887 members (79,349 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C Visual-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:36am
Comments
Andrew Cherednik at 3-Nov-12 18:20pm
   
you have specified many tags: C, C++, Visual Studio. What technology are you planning to use? strtok is C

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
v2

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

  Print Answers RSS
0 CHill60 280
1 Sergey Alexandrovich Kryukov 264
2 OriginalGriff 170
3 Andy Lanng 160
4 Richard MacCutchan 130
0 CHill60 280
1 Sergey Alexandrovich Kryukov 125
2 Andy Lanng 120
3 Abhinav S 95
4 Maciej Los 95


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100