www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/11/19:30:34

Xref: news2.mv.net comp.os.msdos.djgpp:4855
From: calvid AT cortez DOT its DOT rpi DOT edu (David J. Calvin)
Newsgroups: comp.os.msdos.djgpp
Subject: Question about pointers
Date: 10 Jun 1996 16:26:23 GMT
Organization: its
Lines: 33
Message-ID: <4phibg$sek@usenet.rpi.edu>
NNTP-Posting-Host: cortez.its.rpi.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This is probably something I should know, but I'm just not sure how
this works.  Suppose you have this:

struct big
{
	int array[10000];
}

Obviously this is going to take up a decent amount of memory.  If an
int takes 4 bytes, it'll be about 40k.  Now suppose you do this:

big zero;
big *one;
big *two;
big *three;

one = two = three = &zero;

Here's what I'd like to know:

1) Obviously the first line, big zero, will allocate 40k of memory
to store itself in.  But what about big *one, etc?  Do they also
take up 40k of memory, or just enough space to hold an address?

2) In the one=two=three=&zero line, do the pointers now take up 40k
of memory each, or just enough to hold an address?

What I really need to know is if you can make many pointers pointing
to one variable and save memory that way.  Thanks in advance.

Dave Calvin
calvid AT rpi DOT edu

- Raw text -


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