7 AnswersNew Answer
Did you remember to dereference the pointer when printing it?
Well no, it's not an integer, it could be one of 2 things: 1– the address of the integer being pointed to 2– the address of the pointer. Since you stated that 0xbu77io was not an integer, I assumed you were asking why you don't get the integer. I apologize for the misunderstanding, but you should clarify that in your question. By the way, int *pointer is NOT a string variable. It's a pointer to an integer.
You can declare a pointer of any type. Pointers are just memory that holds the location of one or more items of a certain type. So an int pointer is a variable that holds the address of one or more int values.
Ace This is not my question you didnt understand me ^_^
why that is not mistake to declare pointer as integer ... this as so clear answer it please .... 😚😙😗
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).
Ace Thank you pro ^_^