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. Equivilant of JScript's "split" in C++

Equivilant of JScript's "split" in C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelpquestion
3 Posts 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I’ve been trying for most of the day now to write a function that is basically the same as JScript's split function (you pass a string containing one or more key letters, and the key letter, and the function returns an array [or list] of the strings). e.g. (pseudo code).

    CStringList Foo::Split(CString strBigString, CString srtKeyletter)
    {
    .. do stuff here that creates an array of keyletter delimited strings

    return [CStringList containing the strings]
    }

    However, I can’t get it to work. Not even slightly! Could anyone here help? Yours, Peter

    J 1 Reply Last reply
    0
    • L Lost User

      Hi, I’ve been trying for most of the day now to write a function that is basically the same as JScript's split function (you pass a string containing one or more key letters, and the key letter, and the function returns an array [or list] of the strings). e.g. (pseudo code).

      CStringList Foo::Split(CString strBigString, CString srtKeyletter)
      {
      .. do stuff here that creates an array of keyletter delimited strings

      return [CStringList containing the strings]
      }

      However, I can’t get it to work. Not even slightly! Could anyone here help? Yours, Peter

      J Offline
      J Offline
      John Connah
      wrote on last edited by
      #2

      Hi Peter, are you after a strtok or wstrtok type function. Its a c library call that tokenizes as you describe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/\_crt\_strtok.2c\_.wcstok.2c\_.\_mbstok.asp or use the CString FindOneOf to implement what you want John

      L 1 Reply Last reply
      0
      • J John Connah

        Hi Peter, are you after a strtok or wstrtok type function. Its a c library call that tokenizes as you describe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/\_crt\_strtok.2c\_.wcstok.2c\_.\_mbstok.asp or use the CString FindOneOf to implement what you want John

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thanks, i've managed to write a function using wstrtok that does exactly what I wanted.

        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