HDTenEightyP/NetNews huggingface dataset:
From: REGI's <NUNEZ@esevvx.cica.es>
Newsgroups: vmsnet.internals
Subject: (None)
Date: Thu, 15 Oct 1992 16:30:00 UTC+0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

>X-Envelope-to: MACRO32@WKUVX1.bitnet
>X-VMS-To: IN::"MACRO32@WKUVX1.BITNET"

1
13-OCT-1992 01:54:54.54
   1 00:00:00.00
14-OCT-1992 01:54:54.54
@UKCC.uky.edu:MacroMan@WKUVX1.BITNET
gutier@SEVAXU.CICA.ES

Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 10-OCT-1992 01:54:52.76
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 6842; Fri, 09 Oct 92 20:53:48 EDT
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 9696;
 Fri, 09 Oct 92 20:53:46 EDT
Errors-To: MacroMan@WKUVX1.BITNET
X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
    <MACRO32@WKUVX1.BITNET>
Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Fri, 09
          Oct 1992 19:50:34 CDT
Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 6612; Fri,
          09 Oct 92 20:37:36 EDT
Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
          Fri, 09 Oct 92 20:37:34 EDT
From: <gjc@mitech.com>
Reply-To: MACRO32@WKUVX1.BITNET
X-Newsgroups: vmsnet.internals
Subject: Re: Shared images, some differences on ALPHA
Date: 9 Oct 92 14:37:13 GMT
Organization: Mitech Corporation, Concord MA
To: MACRO32@WKUVX1.BITNET
X-Gateway-Source-Info: USENET

In article <1992Oct8.151434.719@cmkrnl.com>, jeh@cmkrnl.com writes:
> That's odd -- I could'a sworn that globalREF's would become extern's.   To
> actually define the space (equivalent of globaldef), you use an unadorned
> declaration (no 'extern') outside all procedure bodies.  That's how I was told
> to do it by one of the DEC Alpha folks in Atlanta...

It could be that the VMS ALPHA compilers have some VAX-C compatibility in them,
such that (sort of)

#define globaldef
#define globalref extern

but it could be that whoever was hacking OSF-MOTIF decided to RUB IT IN
that there was something funny about VMS on the VAX, or perhaps an early
version of the VMS ALPHA C compiler didn't have those two trivial items.

-gjc
From: REGI's <NUNEZ@esevvx.cica.es>
Newsgroups: vmsnet.internals
Subject: (None)
Date: Thu, 15 Oct 1992 16:31:00 UTC+0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

>X-Envelope-to: MACRO32@WKUVX1.bitnet
>X-VMS-To: IN::"MACRO32@WKUVX1.BITNET"

1
13-OCT-1992 01:45:27.14
   1 00:00:00.00
14-OCT-1992 01:45:27.14
@UKCC.uky.edu:MacroMan@WKUVX1.BITNET
gutier@SEVAXU.CICA.ES

Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 10-OCT-1992 01:45:25.27
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 6828; Fri, 09 Oct 92 20:44:20 EDT
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 9512;
 Fri, 09 Oct 92 20:44:19 EDT
Errors-To: MacroMan@WKUVX1.BITNET
X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
    <MACRO32@WKUVX1.BITNET>
Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Fri, 09
          Oct 1992 19:41:37 CDT
Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 6606; Fri,
          09 Oct 92 20:37:33 EDT
Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
          Fri, 09 Oct 92 20:37:29 EDT
From: <gjc@mitech.com>
Reply-To: MACRO32@WKUVX1.BITNET
X-Newsgroups: vmsnet.internals
Subject: Re: Shared images, some differences on ALPHA
Date: 9 Oct 92 14:21:07 GMT
Organization: Mitech Corporation, Concord MA
To: MACRO32@WKUVX1.BITNET
X-Gateway-Source-Info: USENET

In article <1992Oct9.054726.1@cc.curtin.edu.au>, zrepachol@cc.curtin.edu.au
 (Paul Repacholi) writes:
> In article <3026@mitech.com>, gjc@mitech.com (George J. Carrette) writes:
>>      #if defined(VMS) && !define(ALPHA)
> Would this perchance be a VAX-C/DEC-C difference, rather than LINK?

False. Globaldef is something that the C compiler is telling the linker.
It is the linker that is responsible for wanting that kind of info in
the first place.

If DEC-C was running on VAX/VMS it would need to have something
like GLOBALDEF to talk to the LINK command properly.
From: 737ochs@gw.wmich.edu
Newsgroups: vmsnet.internals
Subject: Re: Finding a users disk name
Date: 7 Oct 92 14:09:50 EST
Organization: Western Michigan University

In article <7OCT199213391031@jhuvms.hcf.jhu.edu>, ecf_stbo@jhuvms.hcf.jhu.edu (Feet...!? You had FEET?) writes:
> In article <1992Oct7.084705.1063@galaxy.gov.bc.ca>, EWILTS@GALAXY.GOV.BC.CA writes...
>>The only place the user's default device and directory is stored is in
>>SYSUAF.DAT.  Any method you choose for determining the device must have read
>>access to this file.  This doesn't require "operator privileges" - READALL,
>>SYSPRV, or BYPASS will suffice, or you can install the image you use to get the
>>default with privilege so that the end user doesn't need them.
> 
> Actually I'm reasonably sure any user can get the information (for 
> themselves) by calling $getuai. And I think what this guy was asking
> for is as simple as translating the logical name SYS$LOGIN. Not really
> much of an internals question.

Well, actually I don't need SYS$LOGIN, that will only get MY disk area,
I'm looking for a way to say from my account cd ~joeschmo and I need the
function to perform SET DEFAULT DISK$BLAH:[JOESCHMO]
mainly I need to find out what disk pack the user is on, and if they are in
a group, which group they are in, for example, an account might look like this
DISK$CS:[CSxxx.username]
I would need to be able to find the DISK$CS and the CSxxx
And thanks for the replies so far, but I willnot be able to get the sys admin
to install it for me to get sys privs for the program.
Thanks
Fred Ochs
Xref: sparky vmsnet.internals:1437 vmsnet.misc:910 comp.lang.c:14795
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
Subject: Re: malloc() as a user defined function
Summary: a new() idea
Date: 11 Oct 92 05:47:08 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Followup-To: vmsnet.internals
Organization: University of Arizona

In article <Bvv6pH.Gzy@cs.psu.edu>, ytang@red (Yuan-Ling Tang) writes:
>    In programming on dynamic memory allocation, I prefer doing check on
>    every malloc(). I.e.:
>
>    if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
>	printf("Malloc error.\n");
>	exit(0);
>    }
>
>    It turned out it's a pain to type in the above four lines if I have 
>    lots of malloc() invocations in the program, also, the program looks
>    ugly. So I tried to use a function called my_malloc():
>
>    SOME_TYPE *my_malloc()

[deleted, coded as above]
>
>    [...] what if I have many distinct types of memory space to allocate?

Here's an idea I cribbed off of a compiler I worked on last semester (the
source is up for ftp, so it should be OK to use & distribute freely):

Somewhere, I have the following function:

	void *mustalloc( size_t size ) {
	  void *t = malloc(size) ;
	  if( t == NULL ) FATAL( "malloc returns NULL" ) ;
	  return t ;
	  }

FATAL(), of course, is just a simple print 'n' exit routine, which I made
a seperate subroutine since such a thing is often genrally useful in a
large program.


Along with it, I have the following macros:

	extern void *mustalloc( size_t ) ;

	#define  new(t  ) ((t *)mustalloc( sizeof(t) ))
	#define anew(t,s) ((t *)mustalloc( sizeof(t) * (s) ))

With this, I can write code like

	struct foo *p = new(struct FOO) ;
	struct foo foo_array = anew(struct FOO, 100) ;

This provides the advantages of a clean interface to a properly typed
dynamic allocation routine, while hiding the ugly details.  An added
benefit is that if you do all your allocation through mustalloc(), you
automatically have a place to put malloc() wrapper code if you need to
do malloc()/free() debugging (or a place to do garbage collection, if
you prefer).

I've been using this pretty much since I saw it.  IMHO, it works really
great, and I would encourage others to try it too.

-- 
Caught an internal error--.brainrc restored
From: "GWDGV1::MOELLER" <moeller@gwdgv1.dnet.gwdg.de>
Newsgroups: vmsnet.internals
Subject: RE: Help! (sys$init_vol)
Date: Wed, 14 Oct 1992 10:38:33 +0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

Ehud Gavron <GAVRON@IT.SUNQUEST.COM> writes:
>        I'm trying to create a piece of code to initialize a disk or
>        tape volume.  However, when I call sys$init_vol I get back
>        ss$_badparam.  Can anyone either
>                a. tell me what I'm doing wrong
>                b. show me how to do it right?
>[...]
>      char *list_pointer;
>[...]
>     list_pointer = (char *)&initlist[0];
>[...]
>     i =sys$init_vol((char *)device_name,(char *)volume_label,&list_pointer);

Try to pass `initlist' by reference, i.e. drop `&' from the argument list.

BTW, in case you want to install this program with VOLPRO privilege,
you may be in for a nasty surprise: SYS$INIT_VOL(), when applied to *tapes*,
checks for PROCPRV and not for CURPRV (the code for disks is o.k.).
I SPR'ed this last year for VMS 5.4-2. For a workaround, I'm now calling
SYS$INIT_VOL() from EXEC mode with temporarily elevated PROCPRV ...

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
PSI%(0262)45050352008::MOELLER      Phone: +49 551 201516 | No claim intended!
Internet: moeller@gwdgv1.dnet.gwdg.de   | This space intentionally left blank.
From: markh@csd4.csd.uwm.edu (Mark)
Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
Subject: Re: malloc() as a user defined function
Date: 15 Oct 1992 15:41:34 GMT
Organization: Computing Services Division, University of Wisconsin - Milwaukee
NNTP-Posting-Host: 129.89.7.4

In article <Bvv6pH.Gzy@cs.psu.edu> ytang@red.crayola.cs.psu.edu (Yuan-Ling Tang) writes:
>
>Hi netters:
>
>    In programming on dynamic memory allocation, I prefer doing check on
>    every malloc(). I.e.:
>
>    if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
>	printf("Malloc error.\n");
>	exit(0);
>    }
>
>    It turned out it's a pain to type in the above four lines if I have 
>    lots of malloc() invocations in the program, also, the program looks
>    ugly. So I tried to use a function called my_malloc():

Well, then don't type the lines. ;)

First declare dynamic pointer types like so:

typedef struct Type *Type;

instead of

typedef struct Type Type;

Second, eliminate the reference to the base type:

    if ((p=(Type)malloc(sizeof *p)) == NULL) {
	printf("Malloc error.\n");
        exit(0);
   }

Third, rationalize the parentheses away:

   p = (Type)malloc(sizeof *p);
   if (p == NULL) {
       printf("Malloc error.\n");
       exit(0);
   }

Fourth, if you don't like the curly brackets, then rationalize them away too:

   p = (Type)malloc(sizeof *p);
   if (p == NULL)
       printf("Malloc error.\n"),
       exit(0);

Fifth, if you don't like the extra lines, eliminate them:

   p = (Type)malloc(sizeof *p);
   if (p == NULL) printf("Malloc error.\n"), exit(0);

And sixth, if you don't like the extra typing, remove the NULL:

   p = (Type)malloc(sizeof *p);
   if (p == 0) printf("Malloc error.\n"), exit(0);

There.  Now how does that compare with this?

>    if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
>	printf("Malloc error.\n");
>	exit(0);
>    }

If you furthermore want your program to crash on malloc failures, then
write a functon for this routine:

void *Allocate(int Size) {
   void *X = malloc(Size);
   if (X == 0) printf("Malloc error.\n"), exit(0);
}

and use it in place of the two lines above:

p = (Type)Allocate(sizeof *p);

Better?
From: MILLER@TGV.COM
Newsgroups: vmsnet.internals
Subject: Re:  C Language question
Date: 8 Oct 92 21:49:34 GMT
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List


>Question: in C, if one declares char a[I][J], is there anything in the

Remember:  a[i] really means *(a+i) using the rules for pointer addition.
a[i] is a macro construct.

So a[i][j] really works out to *((char *)&*(a+i) + j), I think.
So "a" has an "element size" if J characters in this context.
If we declare "char *b = a;" then the following should work:

        a[i][b] == *((b+i*J) + j)

and

        &a[i][b] == ((b+i*J) + j)

In as much as linear array elements are contiguous, so are multi-
dimentional array elements, since they are simply arrays of arrays.

Check K&R for details (see pointer arithmatic, and multinet-dimentional
arrays).  I have no idea what ANSI has to say on the subject.

-bruce
From: 737ochs@gw.wmich.edu
Newsgroups: vmsnet.internals
Subject: Finding a users disk name
Date: 7 Oct 92 03:10:40 EST
Organization: Western Michigan University

Hello, I'm helping a friend of mine write a program that kinda simulates
a unix-type operating system. What we are having trouble with is the
cd ~user  command. We don't know how to get the person's disk area name
from their username. We'd like to be able to do cd ~user and have the 
program give us back disk$xxx:[user]. Is there an easy way to do this, 
and a way to do it without having operator privileges. Oh, we are using
VMS version 5.5
Please e-mail replies,
Thanks,
Fred Ochs
From: REGI's <NUNEZ@esevvx.cica.es>
Newsgroups: vmsnet.internals
Subject: (None)
Date: Thu, 15 Oct 1992 15:32:00 UTC+0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

>X-Envelope-to: macro32@WKUVX1.bitnet
>X-VMS-To: IN::"macro32@WKUVX1.BITNET"

1
14-OCT-1992 00:51:51.01
   1 00:00:00.00
15-OCT-1992 00:51:51.01
@UKCC.uky.edu:MacroMan@WKUVX1.BITNET
gutier@SEVAXU.CICA.ES

Received: from UKCC.uky.edu by ESEVVX.CICA.ES ; 11-OCT-1992 00:51:48.32
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 9449; Sat, 10 Oct 92 19:50:42 EDT
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 2626;
 Sat, 10 Oct 92 19:50:40 EDT
Errors-To: MacroMan@WKUVX1.BITNET
X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
    <MACRO32@WKUVX1.BITNET>
Received: from UGA.CC.UGA.EDU (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Sat, 10
          Oct 1992 18:10:58 CDT
Received: from UGA by UGA.CC.UGA.EDU (Mailer R2.08 PTF008) with BSMTP id 0872;
          Sat, 10 Oct 92 12:23:08 EDT
Received: from inet-gw-2.pa.dec.com by uga.cc.uga.edu (IBM VM SMTP V2R2) with
          TCP; Sat, 10 Oct 92 12:23:07 EDT
Received: by inet-gw-2.pa.dec.com; id AA08167; Sat, 10 Oct 92 09:24:02 -0700
Received: by vbormc.vbo.dec.com; id AA20403; Sat, 10 Oct 92 17:19:11 +0100
Received: from taveng.enet; by vbormc.enet; Sat, 10 Oct 92 17:19:17 MET
Date: Sat, 10 Oct 92 17:19:17 MET
X-MX-Warning:   Warning -- Invalid "From" header.
From: Yaacov Fenster @ISO 882-3153  10-Oct-1992 1823
      <fenster@taveng.enet.dec.com>
Reply-To: MACRO32@WKUVX1.BITNET
To: macro32@WKUVX1.BITNET
CC: fenster@taveng.enet.dec.com
Apparently-To: macro32@wkuvx1.bitnet
Subject: RE: malloc() as a user defined function

> From: VBORMC::"MACRO32@WKUVX1.BITNET" "MAIL-11 Daemon"  9-OCT-1992 21:28:56.38
> To:   MACRO32@WKUVX1.BITNET
> CC:
> Subj: malloc() as a user defined function
>
>
> Hi netters:
>
>     In programming on dynamic memory allocation, I prefer doing check on
>     every malloc(). I.e.:
>
>     if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
>         printf("Malloc error.\n");
>         exit(0);
>     }
>
>     It turned out it's a pain to type in the above four lines if I have
>     lots of malloc() invocations in the program, also, the program looks
>     ugly. So I tried to use a function called my_malloc():
>
>     SOME_TYPE *my_malloc()
>     {
>         SOME_TYPE *p;
>
>         if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
>             printf("Malloc error.\n");
>             exit(0);
>         }
>         return(p);
>     }
>
Try my_malloc() returning type of "void *", this will convert into any "type *"
type.

        Yaacov

-------------------------------------------------
Yaacov Fenster                  +(972)-3-9307239
y.fenster@ieee.org
fenster@taveng.enet.dec.com     DTN 882-3153
All the opinions voiced are mine alone and do not reflect anyone else's
opinion. (Including Dec).
Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
From: ytang@red.crayola.cs.psu.edu (Yuan-Ling Tang)
Subject: malloc() as a user defined function
Organization: Penn State Computer Science
Date: Fri, 9 Oct 1992 17:17:40 GMT


Hi netters:

    In programming on dynamic memory allocation, I prefer doing check on
    every malloc(). I.e.:

    if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
	printf("Malloc error.\n");
	exit(0);
    }

    It turned out it's a pain to type in the above four lines if I have 
    lots of malloc() invocations in the program, also, the program looks
    ugly. So I tried to use a function called my_malloc():

    SOME_TYPE *my_malloc()
    {
	SOME_TYPE *p;

        if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
    	    printf("Malloc error.\n");
	    exit(0);
        }
	return(p);
    }

    However another problem arises, what if I have many distinct types
    of memory space to allocate? That is, I can't use the same type in
    calling my_malloc(). So how can I pass a type to a function?

    Thanks for your reponse.

- Tang
From: REGI's <NUNEZ@esevvx.cica.es>
Newsgroups: vmsnet.internals
Subject: (None)
Date: Thu, 15 Oct 1992 16:50:00 UTC+0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

>X-Envelope-to: MACRO32@WKUVX1.bitnet
>X-VMS-To: IN::"MACRO32@WKUVX1.BITNET"

1
12-OCT-1992 20:01:57.47
   1 00:00:00.00
13-OCT-1992 20:01:57.47
@UKCC.uky.edu:MacroMan@WKUVX1.BITNET
gutier@SEVAXU.CICA.ES

Received: from UKCC.uky.edu by ESEVVX.CICA.ES ;  9-OCT-1992 20:01:54.99
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 5398; Fri, 09 Oct 92 14:59:39 EDT
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 2280;
 Fri, 09 Oct 92 14:59:38 EDT
Errors-To: MacroMan@WKUVX1.BITNET
X-ListName: "VMS Internals, MACRO, and BLISS Discussions"
    <MACRO32@WKUVX1.BITNET>
Received: from CUNYVM.BITNET (MAILER) by WKUVX1 (MX V3.1C) with BSMTP; Fri, 09
          Oct 1992 13:45:16 CDT
Received: from CUNYVM by CUNYVM.BITNET (Mailer R2.08) with BSMTP id 9601; Fri,
          09 Oct 92 13:47:31 EDT
Received: from MVB.SAIC.COM by CUNYVM.CUNY.EDU (IBM VM SMTP V2R2) with TCP;
          Fri, 09 Oct 92 13:47:29 EDT
X-Newsgroups: vmsnet.internals,vmsnet.misc,comp.lang.c
From: <ytang@red.crayola.cs.psu.edu>
Reply-To: MACRO32@WKUVX1.BITNET
Subject: malloc() as a user defined function
Organization: Penn State Computer Science
Date: Fri, 9 Oct 1992 17:17:40 GMT
To: MACRO32@WKUVX1.BITNET
X-Gateway-Source-Info: USENET


Hi netters:

    In programming on dynamic memory allocation, I prefer doing check on
    every malloc(). I.e.:

    if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
        printf("Malloc error.\n");
        exit(0);
    }

    It turned out it's a pain to type in the above four lines if I have
    lots of malloc() invocations in the program, also, the program looks
    ugly. So I tried to use a function called my_malloc():

    SOME_TYPE *my_malloc()
    {
        SOME_TYPE *p;

        if ((p=(SOME_TYPE *)malloc(sizeof(SOME_TYPE))) == NULL) {
            printf("Malloc error.\n");
            exit(0);
        }
        return(p);
    }

    However another problem arises, what if I have many distinct types
    of memory space to allocate? That is, I can't use the same type in
    calling my_malloc(). So how can I pass a type to a function?

    Thanks for your reponse.

- Tang
From: "Andy, Systems Manager" <UDAA055@ELM.CC.KCL.AC.UK>
Newsgroups: vmsnet.internals
Subject: RE: C Language question
Date: Thu, 8 Oct 92  12:39 BST
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List

Nigel Arnot writes:

>Question: in C, if one declares char a[I][J], is there anything in the
>language standard that guarantees that &a[0][0] is the first of a set of
>I*J contiguous chars, and that a[i+1][0] is guaranteed to be the same
>storage location as a[i][J] ).
>

I suppose that it is conceivable for a compiler to use a mechanism for indexing
that allows the individual elements of an array to be scattered in virtual
memory. Assuming this is not the case then I think the following explanation
holds.

A single `dimensioned' array or vector, such as a[i], is contiguous in memory
in any language. (Obviously, otherwise indexing couldn't work).

So:

   int a[i]

simply states that a is an array of contiguous ints (i of them).

Now if we consider a two dimensional array, such as a[i][j], as a vector where
each element is itself a vector (as I believe the C standard does, although
maybe only implictly rather than explicitly), then clearly the same rules apply.

So:

   int a[i][j]

could be considered as:

   typedef int vector[i];
   vector  a[j];

where a is still a vector, but each element is a contiguous array of integers.

Clearly all the elements of a must therefore be contiguous!

This tends to be borne out by most C compilers; I dont think I've ever met one
that allocates the space non contiguously. That's not proof of course, merely
the implementor's interpretation of the standard but, I think, an accurate one.


>A friend asserts that it is, and says his experience on several systems
>'proves' this. My belief is that there is nothing that says this will
>always be the case, and that the only constraint is that every valid pointer
>a[i] will point to J chars. Which of us is right?


C is certainly confusing in this area in that, although pointers and arrays are
often interchangeable, what you are ACTUALLY allowed to do and how the storage
is allocated, depends on how you originally define the arrays.

For example:

   char c[10]="123456789";
   char *c = "123456789";

Initially, the program sees a similar data structure, but the programmer has
different constraints on each. For example:

  1.   c = &x  is invalid for the first but ok for the second.

  2.   The first declaration allocates storage in writeable memory and then
       initializes it.  The second however sets the data up in read-only
       memory and sets c to point at it.

Nigel's assertion is correct only if the array has been declared slightly
differently:

   typedef char string[j]
   string *a[i]

Where a is defined as an array of pointers to string.  Although the syntax is
similar, the meaning is somewhat different.


Andy Harper
Kings College London, England