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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:18:07+00:00 2026-05-21T05:18:07+00:00

Value of a pointer is address of a variable. Why value of an int

  • 0

Value of a pointer is address of a variable. Why value of an int pointer increased by 4-bytes after the int pointer increased by 1.

In my opinion, I think value of pointer(address of variable) only increase by 1-byte after pointer increment.

Test code:

int a = 1, *ptr;
ptr = &a;
printf("%p\n", ptr);
ptr++;
printf("%p\n", ptr);

Expected output:

0xBF8D63B8
0xBF8D63B9

Actually output:

0xBF8D63B8
0xBF8D63BC

EDIT:

Another question – How to visit the 4 bytes an int occupies one by one?

  • 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-21T05:18:08+00:00Added an answer on May 21, 2026 at 5:18 am

    When you increment a T*, it moves sizeof(T) bytes.† This is because it doesn’t make sense to move any other value: if I’m pointing at an int that’s 4 bytes in size, for example, what would incrementing less than 4 leave me with? A partial int mixed with some other data: nonsensical.


    Consider this in memory:

        [↓      ]
    [...|0 1 2 3|0 1 2 3|...]
    [...|int    |int    |...]
    

    Which makes more sense when I increment that pointer? This:

                [↓      ]
    [...|0 1 2 3|0 1 2 3|...]
    [...|int    |int    |...]
    

    Or this:

          [↓      ]
    [...|0 1 2 3|0 1 2 3|...]
    [...|int    |int    |...]
    

    The last doesn’t actually point an any sort of int. (Technically, then, using that pointer is UB.)

    If you really want to move one byte, increment a char*: the size of of char is always one:

    int i = 0;
    int* p = &i;
    
    char* c = (char*)p;
    char x = c[1]; // one byte into an int
    

    †A corollary of this is that you cannot increment void*, because void is an incomplete type.

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

Sidebar

Related Questions

My question is: If a pointer variable has the same address as its value,
how can i get the memory address of the value a pointer points to?
I want to convert a pointer *int to its real value int , in
I want to print the address of an access variable (pointer) for debugging purposes.
If I have the following pointer variable declarations: int *a; int **c; Regarding to
For example, after we define a variable: int a=2; we can use a as
What is the default value for a pointer in Visual C++ 6.0. If it
When,i try to assign null value to my pointer,it sometimes crashes on that line.
I have a disappearing pointer db ; the value is properly set during creation
Possible Duplicate: catch exception by pointer in C++ I always catch exceptions by value.

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.