Substring a CString

This is a discussion on Substring a CString within the Windows Programming forums, part of the Platform Specific Boards category; Hi. CString class doesn’t have a substr method. What's the easiest way to substring a CString string? (say, to retrieve ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374

    Substring a CString

    Hi.
    CString class doesn’t have a substr method. What's the easiest way to substring a CString string? (say, to retrieve 5th to 20th chars of a CString).
    THX.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Use the "Mid" member function.

    --
    Mats

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374
    Thanx mats.
    Could u please help me a little bit with this too?: Now, i have to read a html file and extract the links within it. if the user say to retreve all links that points to .zip files, i have to retrieve only those links. so what i'm trying to do is to search for the extention (.zip) 1st, then reverse find that link's (assuming that it's a link) head(http) from there. what do u think the easyest way to reverse find the link head?
    THX again.
    Last edited by geek@02; 08-17-2007 at 07:21 AM.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Hmm. That doesn't sound very trivial to me. I would probably start by scanning for "<a" and "</a>" in pairs, then look inside what I found from that.

    Of course, if you have the whole HTML page as one long string, there are other ways to do it, but searching backwards can have some problems. And beware that I may type "foo.zip" in my web-page without actually the page containing a link to any .zip file at all, so you need to figure out if it's inside a link-tag sooner or later anyways.

    --
    Mats

  5. #5
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    374
    yeah u r right. this reverse-find thing is messy. appriciate your sugesstion about scanning <a tags. thx.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Writing CObjects with Serialization to CArchive
    By ruben_gerad in forum C++ Programming
    Replies: 0
    Last Post: 11-09-2006, 07:25 AM
  3. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  4. Help with CString class and operator+ overloading
    By skanxalot in forum C++ Programming
    Replies: 2
    Last Post: 10-07-2003, 10:23 AM
  5. CString Objects & subString :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 06-19-2002, 07:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21