www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/06/23:20:33

From: Tudor <tudor AT cam DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Question on pointers and arrays
Date: Thu, 06 Feb 1997 16:03:18 -0800
Organization: Communications Accesibles Montreal
Lines: 23
Message-ID: <32FA7146.3883@cam.org>
References: <32f92a6c DOT 0 AT ntnews DOT compusmart DOT ab DOT ca>
Reply-To: tudor AT cam DOT org
NNTP-Posting-Host: dynamicppp-93.hip.cam.org
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Demandred wrote:
> 
> Probably a silly question, but...
> 
> If I declare an array of objects of type Foo
> 
> Foo FooArray[5];
> 
> And pass a pointer to a Foo into a function (or class constructor)
> 
> Bar(Foo *array) {...
> 
> Can I access elements in the array in the function, like so?
> 
> ...array[3]...}
I guess you can.
When you say Foo array[5] then 'array' is actually a pointer to the
first element.
char string[5]="abcde" and
char *string="abcde" are equivalent.
-- 
tudor 'at' cam 'dot' org
'This is Scott Nudds of the Borg. C is irrelevant.'

- Raw text -


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