CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    121

    Copying a string

    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


  2. #2
    Guest

    Re: Copying a string

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured