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. Memory Allocation

Memory Allocation

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelp
6 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.
  • A Offline
    A Offline
    Anil Kumar Arvapalli
    wrote on last edited by
    #1

    I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this... Thanks in Advance... :)

    CPalliniC T L 3 Replies Last reply
    0
    • A Anil Kumar Arvapalli

      I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this... Thanks in Advance... :)

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      The language provides the sizeof operator [^], please use it. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • A Anil Kumar Arvapalli

        I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this... Thanks in Advance... :)

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        Pardhu2 wrote:

        I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this...

        if it string,it would 1 byte per char! if it int, it would be 4 byte per variable! Shoot me down, if i am wrong! :-)

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        L 1 Reply Last reply
        0
        • T ThatsAlok

          Pardhu2 wrote:

          I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this...

          if it string,it would 1 byte per char! if it int, it would be 4 byte per variable! Shoot me down, if i am wrong! :-)

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
          Never mind - my own stupidity is the source of every "problem" - Mixture

          cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          ThatsAlok Shoot me down, if i am wrong!

          say where and when.

          ThatsAlok if it string,it would 1 byte per char!

          1 or 2 bytes per character, also counting the terminating null. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Nil Volentibus Arduum


          CPalliniC 1 Reply Last reply
          0
          • L Luc Pattyn

            ThatsAlok Shoot me down, if i am wrong!

            say where and when.

            ThatsAlok if it string,it would 1 byte per char!

            1 or 2 bytes per character, also counting the terminating null. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Nil Volentibus Arduum


            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            C++ string literals (like to one of the OP) have 1 byte per character (wide character string literals must be L prefixed). They include, as you stated, a terminating 0. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • A Anil Kumar Arvapalli

              I have a the following string "568" and 568(which is int), how memory is allocated for them internally... can any one please help me regrding this... Thanks in Advance... :)

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

              In its simplest (ASCII) form the string "568" will allocate one byte per character and a null byte to signify the end of the string, giving a total of four bytes. If the string uses Unicode encoding then two bytes per character are allocated. If MBCS UTF-8[^] then it may be more than two per character. An integer will be stored as 16, 32, or 64 bits depending on the type of variable: short, int, long, long long etc.

              It's time for a new signature.

              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