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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:10:03+00:00 2026-05-17T16:10:03+00:00

Can someone please explain me this peculiar output: #include <stdio.h> typedef struct node {

  • 0

Can someone please explain me this peculiar output:

#include <stdio.h>

typedef struct node
{
  int i;
  struct node *next;
}node;

main()
{
    node *p,*q;
    printf(" %u ",sizeof(node));              // 16
    p = (node *)malloc(sizeof ( node ) ) ;     
    printf(" %p ",p);                    // 0x1cea010
    q = (node *)malloc(sizeof ( node ) ) ; 
    printf("\n %p ",q);                    // 0x1cea030
}

I have a 64 bit processor. When the size is shown to be 16 byes, why is 32 byte allocated for the node??
I checked out a 32- bit machine. The addresses had a separation of 8 bytes. With no padding and stuff. So is the difference of 4 bytes solely cause of some padding issue of the 64 bit machine??

  • 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-17T16:10:04+00:00Added an answer on May 17, 2026 at 4:10 pm

    Two malloc calls aren’t necessarily going to return consecutive memory areas. A better way to do this test would be:

    main()
    {
        node *p;
        printf(" %u ",sizeof(node));
        p = (node*)malloc(2 * sizeof (node));     
        printf(" %p \n %p ", &p[0], &p[1]);
        free(p);
    }
    

    By allocating an array, you can be sure that they are back-to-back in memory.

    Depending on your implementation of malloc, your system may be using the memory in between p and q to store bookkeeping information that is used by realloc, free, and friends.

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

Sidebar

Related Questions

Can someone please explain why this program outputs 0x00000004? class AndAssignment { static void
Can someone please explain why int (0.4 * 10.0) is 4 yet int ((2.4
I have regex which reads: @<img\s*[^>]*>(?:\s*?</img>)? Can someone please explain this part: (?:\s*?)? What
can someone please explain why the addition of the group by subquery makes this
Can someone please explain to me the below code. This behavior has been like
Can someone please explain why this JavaScript code outputs zero instead of one? Also,
EDIT (Side Question) Can someone please explain what this line does? eval website=\${$#} The
Can someone please explain me what's the difference between Swing and AWT? Are there
Can someone please explain what the & does in the following: class TEST {
In WPF: Can someone please explain the relationship between DependencyProperty and Databinding? I have

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.