0

Y iam not getting address of the variable in printf("\n%u",a); where a is declared as int ..

18th May 2020, 6:37 PM
Eliyas ahamad Shaik
Eliyas ahamad Shaik - avatar
6 Respostas
+ 1
Use &a
18th May 2020, 6:42 PM
Avinesh
Avinesh - avatar
+ 1
Using %u to print addresses is undefined behavior. You must use %p specifier for addresses and cast to a void pointer (this is required by C99): printf("%p\n", (void *)&a); you can read more about it here: https://stackoverflow.com/questions/9053658/correct-format-specifier-to-print-pointer-or-address
18th May 2020, 7:15 PM
Gen2oo
Gen2oo - avatar
0
Then I will get the value of a..
18th May 2020, 6:41 PM
Eliyas ahamad Shaik
Eliyas ahamad Shaik - avatar
0
a returns value.. &a returns address.. printf("%u", &a) ;
18th May 2020, 6:43 PM
Jayakrishna 🇮🇳
0
Ooops..a u r right..thanks to remember me I forget that
18th May 2020, 6:43 PM
Eliyas ahamad Shaik
Eliyas ahamad Shaik - avatar
0
S ..thanks mr.Avinesh and to mr.JayaKrishna
18th May 2020, 6:45 PM
Eliyas ahamad Shaik
Eliyas ahamad Shaik - avatar