confusion of storing variable?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nandadulal
    New Member
    • Jun 2010
    • 8

    confusion of storing variable?

    would anyone tell me when we take a variabel suppose int a; is it create a memory space? when we access a variable with oject .variablename how it shows the value .please, tell how it works in respect or RAM.
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    once the variable is initialised it is assigned memory according to its type for a time according to its scope.

    Comment

    • Babi Basu
      New Member
      • Nov 2010
      • 2

      #3
      Thanks. I also want to know how does it stores variable in ram like in structure it stores one after another and in union it stores from one location? plz. send reply i am confused when i do implemention of programm.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        That is entirely implementation dependent, the C and C++ standards impose no requirements on the way any given platform chooses to store the data it uses in memory.

        If you want an answer at the very least you are going to have to give a lot more detail of what you are doing and what you are trying to understand.

        Comment

        • whodgson
          Contributor
          • Jan 2007
          • 542

          #5
          Please follow Banfa from now as my understanding limited.

          Comment

          • donbock
            Recognized Expert Top Contributor
            • Mar 2008
            • 2427

            #6
            The C Standard imposes certain minimal constraints, such as a short must be able to hold values in at least the range -32768 to 32767. A compiler is free to do whatever it wants as long as it satisfies the minimal constraints. For example, there is no constraint that compilers must use two's-complement encoding for integers.

            The Standard imposes no constraint on the order in which variables are allocated in memory.

            The Standard permits union members to overlap in memory, but I don't recall there being a definite requirement to do so. That is, a lazy compiler could choose to treat union as a synonym for struct.

            The point is that these sort of details vary widely between compilers. There is no answer that is both general and accurate.

            If you want a general answer then you need to say so; if you want an accurate answer then you need to tell us which specific compiler you need an answer for.

            Comment

            Working...