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 8375361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:09:21+00:00 2026-06-09T15:09:21+00:00

This is a question that came up in an exam paper I’m studying for.

  • 0

This is a question that came up in an exam paper I’m studying for.

“Study the code below. Draw a diagram depicting the organisation of a 32-bit
Linux process address space. In your diagram label the approximate locations
of: a, b, c, *c (i.e. the memory pointed to by c), malloc and main”

int a; int b = 10;
int main()
{
  char *c;
  c = malloc(b);
  return (0);
}

Here’s my take on it, please correct me if I’m wrong.

a is an uninitialized global variable and so would be initialised to zero and stored in BSS. b is an initialized global variable and so would go on the data segment. *c is an automatic variable, so would be stored on the stack. c is dynamically allocated, so would go on the heap.
Main is execution code, so would be stored in text.

I’m not sure on the malloc part, is it just program code that would go in text also, or would it be on the stack as a function call?

  • 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-06-09T15:09:22+00:00Added an answer on June 9, 2026 at 3:09 pm

    You are mostly right about the variables. Just one small correction though. c refers to the pointer variable and *c refers to the memory pointed to by c. So c is an automatic variable and goes on stack and *c is dynamically allocated memory so it resides in heap.

    About malloc, the function call maybe made with the help of stack i.e the argument you are passing to malloc may be passed using stack but the function i.e the executable part, it resides in text section. What would happen is that main() would create argument for malloc() on stack, set its value and then set PC=address of malloc(). It is also possible that the argument to malloc is passed using a register instead of stack as there is only one argument but that may vary from compiler to compiler and platform to platform.

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

Sidebar

Related Questions

I am studying for an exam and came across this question that seems a
I came across this question while studying for the Microsoft Web-Application Developer exam, You
I am preparing for my interview and came across this question: Consider that i
This question came about because the cells gem specifies template directories using File.join('app','cells'). That
I found this exam question that I have to tell how the beq instruction
I saw some code yesterday in this question that I had not seen before,
Well, this is another question taken from this practice exam that was given to
I'm preparing to do an .NET exam and I came across this question. I
Edit: Below is my working code based on the feedback/answers I recieved. This question
This is a random question that came to me, obviously I wouldn't want to

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.