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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:07:31+00:00 2026-05-14T14:07:31+00:00

I am trying some programs in c face a problem with this program can

  • 0

I am trying some programs in c face a problem with this program
can any one tell me what is the problem with this and i also want to know that when in the above case if the pointer value is incremented then will it over write the previous value address as

#include<stdio.h>
int main()
{
    int a=9,*x;
    float b=3.6,*y;
    char c='a',*z;
    printf("the value is %d\n",a);
    printf("the value is %f\n",b);
    printf("the value is %c\n",c);
    x=&a;
    y=&b;
    z=&c;
    printf("%u\n",a);
    printf("%u\n",b);
    printf("%u\n",c);
    x++;
    y++;
    z++;
    printf("%u\n",a);
    printf("%u\n",b);
    printf("%u\n",c);
    return 0;
}

suppose that the value we got in the above program (without the increment in the pointer value )is
65524
65520
65519
and after the increment the value of the pointer is
65526(as 2 increment for the int )
65524(as 4 increment for the float )
65520(as 1 increment for the char variable )

then if in that case will the new pointer address overwrite the content of the previous address and what value be contained at the new address

  • 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-14T14:07:31+00:00Added an answer on May 14, 2026 at 2:07 pm

    First of all, I assume your calls to printf are supposed to display the values of x, y and z, or the addresses of a, b, and c, correct? In that case you need to change them to:

    printf("%p\n", x);
    printf("%p\n", y);
    printf("%p\n", z);
    

    These will take into account the size of a pointer on your processor, if that is different from the size of an int. They will also print the address in hexadecimal, which is much more common since addresses can get quite large.

    and after the increment the
    value of the pointer is 65526(as 2
    increment for the int )

    Assuming you’re on a platform where int is 2 bytes (on most modern home PCs int is probably 4 now).

    then if in that case will the new
    pointer address overwrite the content
    of the previous address and what value
    be contained at the new address
    ……plz help

    You haven’t actually dereferenced any of the pointers here. So the memory occupied by a, b, and c is still untouched; all you’ve done is changed what x, y, and z are pointing to. If you were to dereference one of the pointers after incrementing it, you would be modifying memory past the variable it initially pointed to. So if a is at address 65526 decimal and int is 2 bytes:

    int *x = &a; // x points to the integer at "65526" (a)
    x++;         // x points to the integer at "65528", a is still at 65526
    *x = 5;      // you've just modified the memory at addresses 65528 and 65529.
    

    If 65528 or 65529 contained some other important data (like b or c) you’ve just corrupted your program’s state.

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

Sidebar

Ask A Question

Stats

  • Questions 431k
  • Answers 431k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try defining sizes and font weights in relative units. I… May 15, 2026 at 2:19 pm
  • Editorial Team
    Editorial Team added an answer Here's the answer, creating a bat file to delete the… May 15, 2026 at 2:19 pm
  • Editorial Team
    Editorial Team added an answer Python 3 from urllib.error import HTTPError Python 2 from urllib2… May 15, 2026 at 2:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.