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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:53:16+00:00 2026-05-25T01:53:16+00:00

#include <stdio.h> int main (){ int x=10,*a=&x; int *b=(int *)&a; printf(%d %d %d %d

  • 0
#include <stdio.h>
int main (){
int x=10,*a=&x;
int *b=(int *)&a;
printf("%d  %d  %d  %d  %d  %d  ",x,a,*a,b,*b,**b);
return 0;
}

In this little program variable x is assigned value 10 and then address of x is assigned to pointer variable a. Now proper way is int **b=&a because b should be a pointer to pointer. But I thought it’s ultimately the address which gets stored. So to store address of a to an int pointer b, I use typecasting int *b=(int *)&a. Now address of a got stored in b. So if I use *b, it give identical result as a.

But when I extend this further to **b it doesn’t give the same result as *a which I expected. In fact it gives an error. *b and a are same so when i ask to retrieve from this value like **b and *a this doesn’t work. For this I assumed a concept that *b and a are same in value but they are different in type. The value given by a is pointer and value given by *b is an integer so **b is not possible like *a.

But I still think that it should work.

I am using Dev C++ 4.9.9.2 which is a 32 bit compiler. The memory allocated to an int and int * is the same, that is 4 bytes. And *b and a have same bit representation also. So when I write *(*b) I used same value as in *(a). But what is the preventing factor? The format is like *(some bit representation) and the bit representation is identical in case of *b and a. So the value of x should be retrieved. Please explain the preventing factor.

  • 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-25T01:53:17+00:00Added an answer on May 25, 2026 at 1:53 am

    *b is an integer, and you’re not allowed to apply the unary * to an integer. (How would the compiler know whether you expected the bit pattern to point to an int, char, short, or whatever?) You can cast the integer back to a pointer and then deference it: *(int*)*b, which should do what you expect.

    • 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){ char x [] = hello world.; printf(%s \n, &x[0]); return
I just translated this program, #include <stdio.h> int dam[1000][1000]; int main (int argc, const
I've just typed in an example from K&R... #include <stdio.h> int main (int argc,
this program hangs after taking first argument:- #include <stdio.h> #include <conio.h> void ellip(char*,...); int
I have a C Program: #include <stdio.h> int main(){ int b = 10; //assign
#include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits
For this code: #include<stdio.h> void hello() { printf(hello\n); } void bye() { printf(bye\n); }
#include cv.h #include highgui.h #include <stdio.h> int main(int argc, char* argv[]){ cvNamedWindow(Window1, CV_WINDOW_AUTOSIZE); IplImage*
int main(void) { char *input; printf(prompt>); scanf(%s, input); printf(%s, input); return 0; } prompt>input
In a C lab this uber simple code appears: #include <stdio.h> int suma (int

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.