Hi, I've tried to output pointer in decimal but can't do it

int a = 10;
	int* p = &a;
	cout << showbase << dec << p << endl;

it still shows this output in hexadecimal format. Any reason why this doesn't work. Thanks in advance.

Can you summarise the effect in a complete program we can try ourselves, and not just a context-free program fragment that could do anything.

Well, that's what I have in main and I would like to have output from pointer to be in decimal format instead of hexadecimal.

Are you expecting 10 to be printed by that code?

Because that would be cout << showbase << dec << [B]*[/B]p << endl; To actually output a pointer in another base, you'll probably have to cast it to something which isn't a pointer (in other words, ugly)

Maybe cout << showbase << dec << [B](unsigned long)[/B]p << endl; I'm guessing the output of a pointer representation ignores base, because the idea itself is meaningless.

Yes, Salem that is what I was asking for, that is do I have to explicitly cast pointer to another type to print it as "another type". Thank you for your help.