Subj : Re: help on silly code To : borland.public.cpp.borlandcpp From : Abilio Marques Date : Wed Sep 08 2004 11:21 am What I intend to do is make the library user to be able of define tables of double values. As table size can vary from app to app, the user defines a var which is of type fSet. That type defines 2 int vars that says the actual x and y sizes of the array. Then is a pointer to the array itself. When the user writes a table of 2x3 he should put the values 2 and 3 into the sizeX and sizeY vars of the struct. Then he should put the array. The code then checks for the sizeX and sizeY vals, and thats how it knows how much in each dimension is capable to address. I've been able to perform this: double table[] = { 2,3,4, 1,2,3}; fSet a = {2,3,table}; and I guess it did worked (sorry, it was a long time ago). But I'm trying to avoid the definition of table, making the values available in the variable "a". Thanks and forgive me for my bad english "Leo Siefert" escribió en el mensaje news:79vtj098qq7lu3im9ggq0bcudni6m5cp2o@4ax.com... > On Wed, 8 Sep 2004 07:57:22 -0400, "Abilio Marques" > wrote: > > >typedef struct { > > int sizeX; > > int sizeY; > > double *data; > >} fSet; > >... > >fStet b = {2,2, > > {3,4, > > 5,6}}; > > {3,4,5,6} is not a double*. It is an int[4]. > > >typedef struct { > > int sizeX; > > int sizeY; > > char *data; > >} fSet; > > > >fStet b = {2,2,"hello"}; > > "hello" is a const char*. Strictly it should not be allowable unless > the struct contains a const char* member, but many compilers still > allow it a legacy code. This use is deprecated. BC5, however is a > pre-standard compiler and will accept this without comment. > > Now, back to your problem. How would you expect the compiler/the > other program code to know how to process the array you wish to > include in fSet? A char* is terminated by a '\0' byte, so "hello" is > actually a const char[6], and when some function is processing it, the > function can always determine the last character by looking for the > '\0'. > > What do you intend to pass as your data? Always 4 doubles? If so you > can use: > > double data[4]; > > otherwise you will need to include a member to indicate the number of > doubles in the array and you will need to new[] and delete[] the > actual array. > > - Leo .