um... why are you casting it to a void*?
It's still a pointer.

Thanks,
_|_|_|_|_|  _|        _|_|_|_|            
    _|      _|_|_|    _|          _|_|_|  
    _|      _|    _|  _|_|_|    _|        
    _|      _|    _|  _|        _|        
    _|      _|    _|  _|_|_|_|    _|_|_|  
Visit TDS for quality software and website production
http://tysdomain.com
msn: [EMAIL PROTECTED]
aim: st8amnd2005
skype: st8amnd127
  ----- Original Message ----- 
  From: Pedro Izecksohn 
  To: [email protected] 
  Sent: Thursday, September 11, 2008 4:31 PM
  Subject: Res: [c-prog] printing the address of a variable using cout


  -- ~Rick <[EMAIL PROTECTED]> wrote:

  > 
  > 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;

  cerr << (void*)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


   

  __________ NOD32 3435 (20080911) Information __________

  This message was checked by NOD32 antivirus system.
  http://www.eset.com


[Non-text portions of this message have been removed]

Reply via email to