if a pointer has its data typ as integer then how can it store the memory address of a variable which may contain character? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

if a pointer has its data typ as integer then how can it store the memory address of a variable which may contain character?

20th Jun 2016, 7:45 PM
Monic@
Monic@ - avatar
7 Answers
+ 3
Now I get it. What you see is still a number. You may be familiar with the common numbers that have a base of 10, called decimal numbers. What you see is a number to the base of 16, called hexadecimal number. More practically: While for decimal numbers you would count like 0,1,2,3,4,5.6,7,8,9,10,11 and so on you count with hexadecimal numbers like 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11 and so on. Hexadecimal numbers are often chosen to represent binary numbers as each digit of a hexadecimal number represents exactly four digits / bits in the binary format and hexadecimals are easier to read than binary numbers. Btw, for printing to the screen a 0x is usually written before the hexadecimal number (to make them distinct from decimal numbers as 10, and other representations of a number are valid in decimal *and* hexadecimal representation (they only mean 10 and 16 respectively). 10 and 0x10 make it clearer what number representation is meant.
20th Jun 2016, 8:05 PM
Stefan
Stefan - avatar
+ 1
suppose int x int *p p=&x output is 0eex23 which has both integer and character. how?
20th Jun 2016, 7:56 PM
Monic@
Monic@ - avatar
+ 1
No prob ;-)
20th Jun 2016, 8:14 PM
Stefan
Stefan - avatar
+ 1
0eex23 is a address in your computer memory location of created variable
24th Jun 2016, 5:38 AM
Devi Hota
+ 1
thank you stefan
24th Jun 2016, 9:49 AM
Karanveer Singh
Karanveer Singh - avatar
0
What do you mean? The type of a pointer is "pointer to int" (int*)?
20th Jun 2016, 7:50 PM
Stefan
Stefan - avatar
0
got it now! thank-you genius stefan
20th Jun 2016, 8:08 PM
Monic@
Monic@ - avatar