+ 2

Why this code giving me warning in sololearn compiler ( not blaming ) but not in pc ?

https://code.sololearn.com/cxQfGt0syW71/?ref=app

21st Mar 2022, 6:16 PM
Abhay mishra
Abhay mishra - avatar
7 odpowiedzi
+ 1
Integer can hold only 4bytes data. But address returned is int* is 8bytes . You loss data by integer converting. Instead convert to a long type value to see in decimal value.. like printf("address of p is %ld", (long) p) ; Hope it clears..
21st Mar 2022, 6:45 PM
Jayakrishna 🇮🇳
+ 3
Use %p specifier for accesing in all addresses instead of %d. Address returned is of int* type. you it need to use compatible types...
21st Mar 2022, 6:32 PM
Jayakrishna 🇮🇳
+ 2
use "p" not "d" for printing addresses eg printf("address of a = %p\n", &a);
21st Mar 2022, 6:33 PM
rodwynnejones
rodwynnejones - avatar
+ 1
Jayakrishna🇮🇳 but sir what if i want to see my address in integer form for simplicity ?
21st Mar 2022, 6:38 PM
Abhay mishra
Abhay mishra - avatar
+ 1
Ok Jayakrishna🇮🇳 sir thanks
21st Mar 2022, 7:50 PM
Abhay mishra
Abhay mishra - avatar
0
You're welcome..
21st Mar 2022, 8:35 PM
Jayakrishna 🇮🇳