So, I recently iterated over pointers and links because they are constantly used in resources that I used to learn OpenGL. I noticed that the pointer const char *
seems to behave slightly different than other pointers. To demonstrate, I created this test program:
#include <iostream>
int main() {
int i = 2;
int *pi;
const char *pc = "hello world";
pi = &i;
std::cout << "'hello world' type is " << typeid("hello world").name() << std::endl;
std::cout << "pi is " << pi << std::endl;
std::cout << "*pi is " << *pi << std::endl;
std::cout << "pc is " << pc << std::endl;
std::cout << "*pc is " << *pc << std::endl;
return 0;
}
output:
'hello world' type is char const [12]
pi is 0079FC38
*pi is 2
pc is hello world
*pc is h
. -, const char c = "hello world"
; ? , , , "hello world", char const [12]. , . , , int
(pi
). pc
hello world
, ? ( ) , *pc
, ?