int main()
{
	const char* p  = "Hello";

	cout << sizeof(p) << endl;
}

Why this is 4 ?

Because that's the size of the pointer and not the size of the c-string. Try displaying the pointer with

std::cout << (void*)p << std::endl;

>>Why this is 4 ?
Because it's a ULONG type. A pointer stores Memory addresses, which in turn is stored as an unsigned long.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.