Click to See Complete Forum and Search --> : Copying a string


Sophie
April 15th, 1999, 09:17 AM
void VRLessonRecord::SetPath(const CString &src, const CString &dst, const CString &path )
{


}

I have this function where I want to set the path.

The variable path = "C:\LAVAC\LECONS\L0000001"
src = "C:\LAVAC\LECONS"
dst = "C:\CARO"
I need to be able to switch in the path C:\LAVAC\LECONS to C:\CARO

Can anyone help me!
Thank You

April 15th, 1999, 09:44 AM
I think the following code will help you out.

int SlashIndex = path.ReverseFind('\\');
int PathLength = path.GetLength();

path = dst + path.Right(PathLength - SlashIndex);

However since the CString references in your function are declared as const, you will not be able to perform the last assignment to path. I think you also need to remove the const declaration for the CString reference to path.

Chris