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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:04:21+00:00 2026-05-14T03:04:21+00:00

My question is: If a pointer variable has the same address as its value,

  • 0

My question is: If a pointer variable has the same address as its value, is it really pointing to itself?

For example – in the following piece of code, is a a pointer to itself?

#include<stdio.h>

int main(){
   int* a;
   int b = (int)&a;
   a = b;
   printf("address of a = %d\n", &a);
   printf("  value of a = %d\n", a);
}

If a is not a pointer to itself, then the same question poses again: Can a pointer point to itself?
Also, how is a self pointing pointer useful?

  • 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-14T03:04:21+00:00Added an answer on May 14, 2026 at 3:04 am

    What you’re actually doing there is not having the pointer point to itself. You are using the memory space allocated for the pointer to store the location of the pointer. A pointer to an int points to ints – never to other pointers to ints, including itself.

    For example, let’s say you create a pointer a:

    int * a;
    

    It gets its own spot in memory:

       4     a (5)    6
    [....][00000000][....]
    

    In this simple example, let’s say a is at memory location ‘5’.

    If you were to do this:

    a = (int*)&a;
    

    …the following would happen:

       4     a (5)    6
    [....][00000005][....]
    

    What’s happening here is that a is pointing to what it thinks is an integer at location 5. This also happens to be the same memory location that &a is pointing to, but in the context of what a is pointing to, it’s now pointing to the integer at location 5 – and that integer is 5.

    For example both of these would work:

    cout<<(int)a;//outputs 5
    cout<<*a;//Outputs the integer at memory location 5 - which is 5.
    

    If you wanted to create a pointer to a, you most definitely could – either of these ways:

    int **b = (int**)a;
    

    or

    int ** b = &a;
    

    But it’s very important to realize that a isn’t a pointer to itself. It’s a pointer to the integer at the location it stores – which just happens to be the same as its own location.


    To further show (through an even simpler example) what’s going on, something similar could happen with an int. That is, you can store the memory location of an int within itself:

    int a=999;
    

    a now has a location in memory, and has a value of 999 (we’ll pretend it’s been placed in the memory location ’46’):

      45     a (46)   47
    [....][00000999][....]
    

    It’s in the location ’46’ – if we wanted, we could store this number as an integer within a:

    a=(int)&a;
    
      45     a (46)   47
    [....][00000046][....]
    

    and now a is equal to &a in value, but not in type – a is just an integer, it doesn’t point to itself magically now just because we used it to store its own memory location.

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

Sidebar

Related Questions

As part of answering another question, I came across a piece of code like
Question Can I build a image database/library that has an e-commerce style checkout system
Question says it all, really. My application is a time tracker. It's currently written
I see C books that use the same variable names in the function definition,
Correction: I messed up with the concept of pointer address and the address the
I need to solve the following question which i can't get to work by
As a lot of people pointed out in this question , Lisp is mostly
In another question , a user pointed out that the new keyword was dangerous
Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I
Question as stated in the title.

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.