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

  • SEARCH
  • Home
  • 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 8091313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:01:21+00:00 2026-06-05T20:01:21+00:00

I’d like to ask about memory allocation in 64-bit ubuntu Linux. I have the

  • 0

I’d like to ask about memory allocation in 64-bit ubuntu Linux.

I have the following code

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {
    char buffer_one[8], buffer_two[8];

    printf("Size of char: %u\n", sizeof(char));

    printf("Buffer_two is at %p\n", buffer_two);
    printf("Buffer_one is at %p\n", buffer_one);
}

and when it is run, the following result shows up

$ ./sizeofchar 
Size of char: 1
Buffer_two is at 0x7fff98069910
Buffer_one is at 0x7fff98069900

My question is that even with size of char type is 1 byte and I assume (please correct me if I’m wrong here) Buffer_two and Buffer_one are allocated next to each other, why does the Buffer_two and Buffer_one memory address are allocated 16 bytes apart.

  • 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-05T20:01:23+00:00Added an answer on June 5, 2026 at 8:01 pm

    This is compiler-dependent behavior. Since these are stack-allocated buffers (which really has nothing to do with memory allocation,) it is up to the compiler how the stack local variables are laid out in the stack. You could play with this, but I would guess that all arrays are allocated on the stack in 16-byte increments, for one reason or another.

    If you look at the disassembly, you could see where in the stack frame the variables are set to be. I have a hunch that a char[2] and char[15] both end up taking 16 bytes in the stack frame. Why, I’m not exactly sure. But what I can add, is that the x64 ABI specifies that the stack is always 16-byte aligned, and this type of allocation will make it easy to guarantee that.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have two tables with like below codes: Table: Accounts id | username |
I have some data like this: 1 2 3 4 5 9 2 6
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.