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. ATL / WTL / STL
  4. How to remove the "0" from the starting i.e. from the left of the CString

How to remove the "0" from the starting i.e. from the left of the CString

Scheduled Pinned Locked Moved ATL / WTL / STL
helptutorial
5 Posts 5 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.
  • D Offline
    D Offline
    deadlyabbas
    wrote on last edited by
    #1

    Hi, I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string. Kindly help. Thanks in Advance.

    L P A S 4 Replies Last reply
    0
    • D deadlyabbas

      Hi, I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string. Kindly help. Thanks in Advance.

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

      Probably something like this[^].

      The best things in life are not things.

      1 Reply Last reply
      0
      • D deadlyabbas

        Hi, I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string. Kindly help. Thanks in Advance.

        P Offline
        P Offline
        pratik_mishra35
        wrote on last edited by
        #3

        Use The method CString::Remove like thish CString TempString("0000122334"); TempString.Remove('0');

        1 Reply Last reply
        0
        • D deadlyabbas

          Hi, I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string. Kindly help. Thanks in Advance.

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          Try using CString::TrimLeft() to remove leading characters (see documentation in MSDN), CString::Remove() will remove all instances and not just the leading zeros.

          1 Reply Last reply
          0
          • D deadlyabbas

            Hi, I am having the follwoing CString "0000122334" and I need to remove the starting zeros from the string. Kindly help. Thanks in Advance.

            S Offline
            S Offline
            Shivanand Gupta
            wrote on last edited by
            #5

            here there are two method. method 1: if your string is numeric then first convert into integer and again change into string. eg. CString cs("000012345745"); int num = atoi(cs); cs.Format("%d",num); method 2: eg. CString cs("000012345745"); cs.Trim(); int start=0; while(cs.Mid(start,1)=="0") { start++; } cs= cs.Mid(start);

            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