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. Count the number of characters in a CString

Count the number of characters in a CString

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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.
  • M Offline
    M Offline
    mr2003
    wrote on last edited by
    #1

    Hi, What is the syntax to count the number of characters in a CString ? Ehsan Behboudi

    M M T 3 Replies Last reply
    0
    • M mr2003

      Hi, What is the syntax to count the number of characters in a CString ? Ehsan Behboudi

      M Offline
      M Offline
      monrobot13
      wrote on last edited by
      #2

      You should get able to use the GetLength function.

      strMyString.GetLength();

      - monrobot13

      1 Reply Last reply
      0
      • M mr2003

        Hi, What is the syntax to count the number of characters in a CString ? Ehsan Behboudi

        M Offline
        M Offline
        Mukkie
        wrote on last edited by
        #3

        If you want to save to file, you may want to use GetLength()*sizeof(TCHAR), where TCHAR in Unicode environment is defined as two byte type. :)

        1 Reply Last reply
        0
        • M mr2003

          Hi, What is the syntax to count the number of characters in a CString ? Ehsan Behboudi

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          hi mr2003, you know what, you have a complete part of Visual Studio called MSDN... have you ever heard about it ? ;P if you have a look at CString Class members, i'm sure you can find that answer by yourself... nevermind, everybody start to learn one day... ;) see you later i hope TOXCCT

          M M 2 Replies Last reply
          0
          • T toxcct

            hi mr2003, you know what, you have a complete part of Visual Studio called MSDN... have you ever heard about it ? ;P if you have a look at CString Class members, i'm sure you can find that answer by yourself... nevermind, everybody start to learn one day... ;) see you later i hope TOXCCT

            M Offline
            M Offline
            mr2003
            wrote on last edited by
            #5

            we all have good days and bad days, my friend !!! Ehsan Behboudi

            T 1 Reply Last reply
            0
            • T toxcct

              hi mr2003, you know what, you have a complete part of Visual Studio called MSDN... have you ever heard about it ? ;P if you have a look at CString Class members, i'm sure you can find that answer by yourself... nevermind, everybody start to learn one day... ;) see you later i hope TOXCCT

              M Offline
              M Offline
              Mukkie
              wrote on last edited by
              #6

              Hello! Right! But anyway I know many good coders that know nothing about MFC :) By the way: there exist empty global CString object (I am talking about vc60). By changing that object, every empty one will be initialized by the changed value. It can be achieved by changing newly created CString object in incorrect way of course. (Something like getting to inner char pointer, or calling GetBuffer without a release) Funny results :-D

              1 Reply Last reply
              0
              • M mr2003

                we all have good days and bad days, my friend !!! Ehsan Behboudi

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                ey guy, that was just... a joke! humor!!! :sigh: You're probably better than me in coding, so keep cool man ! TOXCCT

                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