+ 2

🙋🏆 Question : why the alphabets in address are get printed..?🏆🙋

I am trying a code in cpp for displaying address of variable "X" of int data type.... my doubt is if I used format specifier as "%d" then why the address have characters in it...? https://code.sololearn.com/cr8KvHkapn0m/?ref=app

26th Oct 2017, 5:12 AM
Rohit Jadhav
5 Antworten
+ 7
To add to @Nick and @Vincent Blankfield clear responses, just know that pointers are always printed in hexadecimal if not casted
26th Oct 2017, 6:10 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 4
I thinl the value of x is 4232046 and the adress of the variable is 0x28ff1c
26th Oct 2017, 5:45 AM
Nick
Nick - avatar
+ 3
It's hexadecimal number. They go like this: decimal hexadecimal 0 = 0 1 = 1 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7 8 = 8 9 = 9 10 = A 11 = B 12 = C 13 = D 14 = E 15 = F In C++ hex a prefix 0x is used to identify hex numbers. Like 0x11FF. Some calculators (like Windows one) have "programming" mode, where you can convert between hex, dec and other base numbers. https://en.wikipedia.org/wiki/Hexadecimal
26th Oct 2017, 5:45 AM
deFault
+ 1
actually I have tried this code in c & I thought that if i used the format specifier %d then the address of variable should be contained only integers....not a single character in it..I mean.. expected o/p =137285 something like that actual o/p= 13fc56e something like that
26th Oct 2017, 12:51 PM
Rohit Jadhav
0
thanks to all..I got it
27th Oct 2017, 11:20 AM
Rohit Jadhav