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. Parsing CString

Parsing CString

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorial
3 Posts 3 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.
  • C Offline
    C Offline
    Caoimh
    wrote on last edited by
    #1

    I'v got a CString string as follows CString strPacket = "$1234567FFFFFFFF#00 I want to parse the string so that str1 = "1234567" & str2 = "FFFFFFFF" Any suggestions on how to do this At the moment I'm using the following, however there must be an easier way of doing this. m_strRspData = ""; for(i = 1; i < 9; i++){ m_strHex = m_strRspPacket.GetAt(i); m_strRspData += m_strHex; } m_strRspData.MakeUpper();

    R D 2 Replies Last reply
    0
    • C Caoimh

      I'v got a CString string as follows CString strPacket = "$1234567FFFFFFFF#00 I want to parse the string so that str1 = "1234567" & str2 = "FFFFFFFF" Any suggestions on how to do this At the moment I'm using the following, however there must be an easier way of doing this. m_strRspData = ""; for(i = 1; i < 9; i++){ m_strHex = m_strRspPacket.GetAt(i); m_strRspData += m_strHex; } m_strRspData.MakeUpper();

      R Offline
      R Offline
      Robert A T Kaldy
      wrote on last edited by
      #2

      Try Tokenizer class at Codeproject. Robert-Antonio It's a good luck, if you meet a real fink. Then you get a respect to normal, mid-honest people."

      1 Reply Last reply
      0
      • C Caoimh

        I'v got a CString string as follows CString strPacket = "$1234567FFFFFFFF#00 I want to parse the string so that str1 = "1234567" & str2 = "FFFFFFFF" Any suggestions on how to do this At the moment I'm using the following, however there must be an easier way of doing this. m_strRspData = ""; for(i = 1; i < 9; i++){ m_strHex = m_strRspPacket.GetAt(i); m_strRspData += m_strHex; } m_strRspData.MakeUpper();

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Something like:

        int x = 0;
        while (isdigit(strPacket[x]))
        {
        str1 += strPacket[x];
        x++;
        }

        str2 = strPacket.Mid(x);

        However, if you are always breaking between the 8th and 9th characters, just use Left() and Mid().


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        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