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. Struct type and memory

Struct type and memory

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
4 Posts 3 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
    Anonygeeker
    wrote on last edited by
    #1

    It is observed memory will be allocated for a structure only when a structure variable is declared. But when I tried this program, it printed address: #include struct emp{ int age; char name[30]; }emp1; main() { printf("%p is the address\n",&emp1.name); } Why ?

    L 1 Reply Last reply
    0
    • A Anonygeeker

      It is observed memory will be allocated for a structure only when a structure variable is declared. But when I tried this program, it printed address: #include struct emp{ int age; char name[30]; }emp1; main() { printf("%p is the address\n",&emp1.name); } Why ?

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

      Because you have declared the variable emp1. As I have suggested to a number of other people recently, please get hold of a C language study guide and learn, at least, the basics of the language.

      D 1 Reply Last reply
      0
      • L Lost User

        Because you have declared the variable emp1. As I have suggested to a number of other people recently, please get hold of a C language study guide and learn, at least, the basics of the language.

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

        Is it a generational thing? It seems more and more that folks are jumping right into chapter 7 of the book and then getting completely lost when things from the previous 6 chapters are being referenced and they can't understand why or where they came from. :rolleyes:

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        L 1 Reply Last reply
        0
        • D David Crow

          Is it a generational thing? It seems more and more that folks are jumping right into chapter 7 of the book and then getting completely lost when things from the previous 6 chapters are being referenced and they can't understand why or where they came from. :rolleyes:

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

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

          It seems to be, and we are seeing more and more of this type of question here. I guess they have all bought into the idea that you can make a lot of money as a developer with minimal training. Just pray they are not working at your bank or local hospital.

          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