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. Managed C++/CLI
  4. Strings

Strings

Scheduled Pinned Locked Moved Managed C++/CLI
helpdatabase
2 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

    Need to devise code for the following problem String Line Character CharSelect Integer Begin Returns the index of the first occurrence of the character CharSelect in string Line starting from index Begin If Line has value “Most people find this hard” and if CharSelect has value ‘t’ and Begin has value 5 then 18 is returned. Any help much appreciated. Bill

    C 1 Reply Last reply
    0
    • L Lost User

      Need to devise code for the following problem String Line Character CharSelect Integer Begin Returns the index of the first occurrence of the character CharSelect in string Line starting from index Begin If Line has value “Most people find this hard” and if CharSelect has value ‘t’ and Begin has value 5 then 18 is returned. Any help much appreciated. Bill

      C Offline
      C Offline
      Cyric74
      wrote on last edited by
      #2

      String *Line = S"Most people find this hard"; String *char = S"t"; Int16 iBegin = 5; //Substring Line to all characters from iBegin on //Find index of 'char' in the substring Int16 iIndex = Line->Substring(iBegin)->IndexOf( char ); //Index total by adding whatever iIndex found with iBegin Console::Write( iIndex + iBegin ); *** That's probably the most simple way. There are some other ways (using IndexOf/IndexOfAny, or some other string functions that I don't recall at the moment) that may also work for finding a character within a specific range. Cyric

      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