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";
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.