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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:14:19+00:00 2026-06-08T08:14:19+00:00

#include<stdio.h> int main(void){ int *ptr,a,b; a = ptr; b = ptr + 1; printf(the

  • 0
#include<stdio.h>
int main(void){
  int *ptr,a,b;
  a = ptr;
  b = ptr + 1;
  printf("the vale of a,b is %x and %x respectively",a,b);

  int c,d;
  c = 0xff;
  d = c + 1;
  printf("the value of c d are %x and %x respectively",c,d);
  return 0;
}

the out put value is

the vale of a,b is 57550c90 and 57550c94 respectively
the value of c d are ff and 100 respectively%  

it turns out the ptr + 1 actually, why it behave this way?

  • 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-08T08:14:22+00:00Added an answer on June 8, 2026 at 8:14 am

    Consider what a pointer is… it’s a memory address. Every byte in memory has an address. So, if you have an int that’s 4 bytes and its address is 1000, 1001 is actually the 2nd byte of that int and 1002 is the third byte and 1003 is the fourth. Since the size of an int might vary from compiler to compiler, it is imperative that when you increment your pointer you don’t get the address of some middle point in the int. So, the job of figuring out how many bytes to skip, based on your data type, is handled for you and you can just use whatever value you get and not worry about it.

    As Basile Starynkvitch points out, this amount will vary depending on the sizeof property of the data member pointed to. It’s very easy to forget that even though addresses are sequential, the pointers of your objects need to take into account the actual memory space required to house those objects.

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

Sidebar

Related Questions

#include <stdio.h> int main(void) { int a[5]={1,2,3,4,5}; int *ptr=(int*)(&a+1); printf(%d %d\n,*(a+1),*(ptr-1)); return 0; }
#include <stdio.h> int main(void) { int x = 1000; char *ptr = &x; printf(%d\n,*ptr);
#include<stdio.h> #include<conio.h> int main (void) { int a,b,c,d; clrscr(); a=3; b=5; c=a,b; d=(a,b); printf(c=%d,c);
Consider the following program: #include <stdio.h> int main(void) { return 0; } When i
#include<stdio.h> void main(){ int x,y,z; x=y=z=1; z=++x||++y&&++z; printf(%d %d %d \n,x,y,z); getch(); } the
#include <stdio.h> #include <stdlib.h> int main() { void *malloc(size_t size); char *ptr, *retval; ptr
The program is: #include <stdio.h> #include <stdlib.h> int main(void) { char *a=abc,*ptr; ptr=a; ptr++;
#include <stdarg.h> #include <stdio.h> void varfun(int n,...){ va_list ptr; int num; va_start(ptr,n); num=va_arg(ptr,int); printf(\n%d,num);
#include <stdio.h> int my_array[] = {1,23,17,4,-5,100}; int *ptr; int main(void) { int i; ptr
I got the following simple C++ code: #include <stdio.h> int main(void) { ::printf(\nHello,debugger!\n); }

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.