Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString::Find 2

Status
Not open for further replies.

shabnam

Programmer
Oct 3, 2000
26
0
0
US
I want to remove all the "/" from a string. I write the following code

CString str = "c:/home/dir/test1.txt";
int iPos = str.Find("/", 0);

while (iPos > 0)
{
str = str.Mid(iPos + 1);
iPos = str.Find("/", 0);
}


This works fine as long as "/" is not the first character - if the string is
"/home/dir/test1.txt"
iPos is 0.

Find never returns > 0 if the character being searched for is the first character. The MS documentation says that if the character at the nStart (0 in my case) position is excluded from the search if nStart is NOT 0. But even when it is 0 it seems to be getting excluded.
 
CString str = "c:/home/dir/test1.txt";
str.Remove(_T('/'));

Good luck
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top