Hi all,
I am trying to print the address of a variable, not the contents of it.
Using printf, I would say:
printf("Allocated %ld bytes at %p\n", bsize+1, fbuf);
but I want to use the C++ features using cout/cerr. I've tried the
following but get garbage:
long int bsize = 1023;
char *fbuf;
fbuf = new char[bsize+1];
if (fbuf)
{
cerr.flags(ios::dec);
cerr << "Allocated " << (bsize+1) << " bytes at ";
cerr.flags(ios::hex);
cerr << fbuf << endl;
delete [] fbuf;
}
I have searched but can only find ios flags for dec, hex, oct but not
for ptr. What is the "secret" here?
~Rick