Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!megatest!djones
From: djones@megatest.UUCP (Dave Jones)
Newsgroups: comp.lang.c
Subject: Re: Passing sizes of arrays without a separate argument for the length
Message-ID: <810@goofy.megatest.UUCP>
Date: 21 Sep 88 02:41:32 GMT
References: <1033@buengc.BU.EDU>
Organization: Megatest Corporation, San Jose, Ca
Lines: 40


 In article <8809191507.AA17512@ucbvax.Berkeley.EDU> U23405@UICVM (Michael J. Steiner) writes:
)BEFORE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
)main()
){
)     char array[10];
)     ...
)     somefunc(array,10);
)}
)
)AFTER (MY IDEA) : - - - - - - - - - - - - - - - - - - - - - - - - - - - -
)main()
){
)     char array[10];
)     ...
)     array[0] = 10;
)     somefunc(array);
)}
)

Try this:

typedef struct
{
  int size;
  char* contents;
}Var_array;


main()
{
  char contents[10];
  Var_array array;
  array.size = sizeof(contents);
  array.contents = contents;

  somefunc(array);
}

/* Works good. Lasts a long time. */