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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CString pre-pend

CString pre-pend

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 4 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.
  • U Offline
    U Offline
    User 1700925
    wrote on last edited by
    #1

    HI all, is it possible to pre-pend to a CString as opposed to append, ie place a new string at the start of the string instead of the end. Thanks Shane

    D M L 3 Replies Last reply
    0
    • U User 1700925

      HI all, is it possible to pre-pend to a CString as opposed to append, ie place a new string at the start of the string instead of the end. Thanks Shane

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      CString s = _T("Project");
      s = _T("Code") + s;

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

      U 1 Reply Last reply
      0
      • U User 1700925

        HI all, is it possible to pre-pend to a CString as opposed to append, ie place a new string at the start of the string instead of the end. Thanks Shane

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

        Yes, just switch the order of the operands. Something like:

        CString name("is David");
        name = "My name " + name;

        Make sense?


        "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

        1 Reply Last reply
        0
        • M Michael Dunn

          CString s = _T("Project");
          s = _T("Code") + s;

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

          U Offline
          U Offline
          User 1700925
          wrote on last edited by
          #4

          Thanks guys, stupid of me to not even think of that!!!

          1 Reply Last reply
          0
          • U User 1700925

            HI all, is it possible to pre-pend to a CString as opposed to append, ie place a new string at the start of the string instead of the end. Thanks Shane

            L Offline
            L Offline
            Larry J Siddens
            wrote on last edited by
            #5

            You can also use the Insert. Insert( int, PCXSTR ); Insert( int, XCHAR ); Example: CString test( "is a test" ); test.Insert( 0, "This " ); Larry J. Siddens

            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