Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:43:44+00:00 2026-05-25T14:43:44+00:00

I was trying out simple memory allocation on stack and heap in C. int

  • 0

I was trying out simple memory allocation on stack and heap in C.

int x = 2;
int *y = malloc(sizeof(int));

When I view the address of x on stack and the heap address contained in y, I see the following

x stack address : 0xbfe92bb4
heap address in y : 0x 9c4b008

Are these addresses in different format ( as I don’t see the same number hex characters in both of them ) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:43:45+00:00Added an answer on May 25, 2026 at 2:43 pm

    There are three main types of allocations in the usual program model:

    • Static – mostly for global/static variables – it is allocated when the program loads (usually in compile time predefined memory addresses, depending on program loading model).
    • Heap – dynamic allocation (e.g. malloc or new), there can sometimes be more than one ‘memory pool’ from which the allocation takes place
    • Stack – mostly for local variables and function parameters

    The two last types are the ones that allow some kind of dynamic allocation (implemented and used in very different ways), and they are usually either allocated from different areas (which, especially where virtual memory is supported can mean very different addresses) or from different ends of the same area (where allocation of both kinds of memory progresses towards the middle).

    Your case is just different memory areas (the heap address should probably read 0x09c4b008 but the 0 gets lost in the output).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out how much memory my objects take to see how
I was trying out a simple JSF application, in which I need to check
Very confused here, trying out the yuicompressor on a simple javascript file. My js
I'm trying to figure out why a simple query in LINQ is returning odd
I am trying to get put out a simple site, which would pool the
I'm trying to figure out the best way to save a simple one-to-many relationship
I'm trying to figure out how to generate a simple join that uses an
I have a (simple) sitemap and am trying to figure out why a certain
I'm just starting out writing trying to write a simple program in C and
I'm trying to strip all punctuation out of a string using a simple regular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.