delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/01/14:34:06

From: Jeff Weeks <pweeks AT execulink DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: pointer trouble... need help
Date: 1 Mar 1997 18:47:35 GMT
Organization: Internet News Service
Lines: 38
Message-ID: <5f9tk7$2mg@nr1.toronto.istar.net>
NNTP-Posting-Host: news.linkd.net
Mime-Version: 1.0
XPident: Unknown
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This may sound like a stupid question but for the life of me I can't
figure this out.  It involves pointers which I was never really good
with.  I hope someone can (_nicely_) help me out here...

I've got a structure:

typedef struct { int h,c; } buf_data;

and I define two variables and allocate memory for them:

tbuf *buf_data;
bbuf *buf_data;
tbuf = new buf_data[video.max_x];
bbuf = new buf_data[video.max_x];

and now I want to copy the values from bbuf to tbuf.  The following
should work shouldn't it?

tbuf = bbuf;

because it would copy the address of bbuf into tbuf right?  Or am I
totally wrong?  I've tried

tbuf = &bbuf;

but C++ doesn't like that.

Any ideas?

Jeff Weeks

--------------------------------------------
            - Code X Software -
       Programming to a Higher Power
  
  email: mailto:pweeks AT execulink DOT com
  web:	 http://www.execulink.com/~pweeks/
--------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019