Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. String Problem

String Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
41 Posts 13 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R rdop

    I am useing this.

    CString DirPath;
    CString FullPath = _T("C:\\abc\\cd\\as.txt");

    int nPos = FullPath.Find( \_T('\\\\') );
    
    if( nPos >= 0 )
    {
    DirPath = FullPath.Mid( 0, nPos);
    }
    AfxMessageBox(DirPath);
    

    Then i am geting out put C: But i need to C:\abc. Plz tell me what i use. Thanks in advance

    S Offline
    S Offline
    Sandeep Saini SRE
    wrote on last edited by
    #41

    Use ReverseFind() instead of Find().

    CString DirPath;
    CString FullPath = _T("C:\\abc\\cd\\as.txt");
    int nPos = FullPath.ReverseFind( _T('\\') );
    if( nPos >= 0 )
    {
    DirPath = FullPath.Mid( 0, nPos);
    }
    AfxMessageBox(DirPath);

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups