Article View: comp.os.ms-windows.programmer.misc
Article #2555Re: difference between STUFF *stuff & STUFF stuff[]???
From: Chris Marriott
Date: Wed, 06 Jan 1993 20:26
Date: Wed, 06 Jan 1993 20:26
44 lines
2269 bytes
2269 bytes
In article <1993Jan6.084522.25921@emr1.emr.ca> jagrant@emr1.emr.ca writes:
>At the risk of appearing stupid again, I have another (perhaps
>obvious, but not right now at 3:30 AM) question...
> [ Lots of stuff deleted]
>
>So, can someone tell me the difference between the following 2
>statements:
> extern STUFF *stufftable;
> extern STUFF stufftable[];
>with respect to the code generated when I reference stufftable, i.e.:
> stufftable[i].xxx=...
>and explain why it is so dangerous here, but it's perfectly ok
>to use a pointer or a [] in a function declaration.
>--
>John A. Grant jagrant@emr1.emr.ca
>Airborne Geophysics
>Geological Survey of Canada, Ottawa
>
The difference is very simple:
extern STUFF *stufftable
tells the complier that you have a global variable which is a POINTER to
a "stufftable". ie, the global quantity is a 2 or 4-byte pointer.
extern STUFF stufftable[]
tells the compiler that you have a global ARRAY of STUFFs.
The two things are totally different. The reason that it doesn't matter
in a function declaration is that passing the name of an array to a function
is the same as passing a pointer to the start of the array.
Hope this helps,
--
--------------------------------------------------------------------------
| Chris Marriott | chris@chrism.demon.co.uk |
| Warrington, UK | BIX: cmarriott |
| (Still awaiting inspiration | CIX: cmarriott |
| for a witty .sig .... ) | CompuServe: 100113,1140 |
--------------------------------------------------------------------------
Technical Details
Message-ID:
<726351962snz@chrism.demon.co.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chrisReferences:
<1993Jan6.084522.25921@emr1.emr.ca>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc From: chris@chrism.demon.co.uk (Chris Marriott) Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!demon!chrism.demon.co.uk!chris Subject: Re: difference between STUFF *stuff & STUFF stuff[]??? Distribution: world References: <1993Jan6.084522.25921@emr1.emr.ca> Organization: None Reply-To: chris@chrism.demon.co.uk X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19) Lines: 44 Date: Wed, 6 Jan 1993 20:26:02 +0000 Message-ID: <726351962snz@chrism.demon.co.uk> Sender: usenet@demon.co.uk