+ 2
Int pointer !!!
why we declare pointer as integer and the pointer is string variable ... ? for example : int score = 5; int *pointer; pointer = &score; output 0xbu77io 0xbu77io is not integer ?
4 Antworten
+ 1
Ace This is not my question
you didnt understand me ^_^
+ 1
why that is not mistake to declare pointer as integer ... this as so clear answer it please .... 😚😙😗
+ 1
Perhaps this will explain:
int score = 10;
std::cout << &score << "\n";
std::cout << *(&score) << "\n";
int *ptr = &score;
std::cout << ptr << "\n";
std::cout << *ptr << "\n";
You a pointer just stores a memory location.
A memory location must be dereferenced to access its data.
The pointer type tells us _how_ to dereference it: treat it like a char (1 byte), an int (4 bytes), a short (2 bytes) -- 32-bit x86 arch -- and so on. It tells us how to add those N bytes and compute the answer (well, not quite, but let's stick with that analogy).
0
Ace Thank you pro ^_^