Article View: comp.std.c
Article #6238Re: Simple questions about array declarations
From: Doug Gwyn
Date: Mon, 26 Feb 1990 19:17
Date: Mon, 26 Feb 1990 19:17
46 lines
1782 bytes
1782 bytes
In article <25E833AA.15362@paris.ics.uci.edu> rfg@paris.ics.uci.edu (Ronald Guilmette) writes:
-Does this mean that the following declaration is illegal?
- int array1[3] = { 1,2,3 }; /* size is known! */
No, array1 has object type.
-How about the following pair of declarations? Are these legal or illegal?
- extern int array2[3];
- int array2[] = { 1,2,3 }; /* size is known! */
array2 has object type.
-Now assuming that the above pair of declarations is legal, how about the
-following pairs? Are these legal?
- extern int array3[4]; /* size = 4 words */
- int array3[] = { 1,2,3 }; /* size = 3 words! */
array3 has object type. Because you omitted the fourth initializer,
array3[3] starts off containing a 0 value.
- extern int array4[3]; /* size = 3 words */
- extern array4[] = { 1,2,3,4 }; /* size = 4 words */
array 4 has object type. You have specified too many initializers
and should get a diagnostic.
- extern int array5[4];
- int array5[3];
These types are not compatible; error.
- extern int array6[3];
- int array6[4];
Ditto.
- static int array7[];
- static int array7[3] = { 1,2,3 };
- static int array8[3];
- static int array8[3] = { 1,2,3 };
- static int array9[3];
- static int array9[] = { 1,2,3 };
- static int array10[];
- static int array10[] = { 1,2,3 };
All these are okay.
Technical Details
Message-ID:
<12235@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!smoke!gwynReferences:
<25E833AA.15362@paris.ics.uci.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Simple questions about array declarations Message-ID: <12235@smoke.BRL.MIL> Date: 26 Feb 90 19:17:59 GMT References: <25E833AA.15362@paris.ics.uci.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 46