Hi all,
I am trying to use a 2-dimensional array [x][y] in which I need to dynamically allocate the x-dimension.
I have created the array as follows:
...blah blah....tmp assigned.
x = tmp;
#define MAX_LINE_LENGTH 500
char (*styledata)[MAX_LINE_LENGTH];
styledata = new char[x][MAX_LINE_LENGTH];
which I thought was alright. I then want to copy a string into each element of the array which I have attempted to do
by accessing a pointer to that element as follows:
char *dataptr;
for (int i=0;i=y;++i)
{ dataptr = &styledata[0];
strcpy(dataptr,appropriate string);
}
This UAE's.
Been staring at it for a while now and either I'm missing the blindingly obvious, have approached the whole thing wrongly or it's kinda subtle.
Can anyone shed some light on this...
Thx for your time.
I am trying to use a 2-dimensional array [x][y] in which I need to dynamically allocate the x-dimension.
I have created the array as follows:
...blah blah....tmp assigned.
x = tmp;
#define MAX_LINE_LENGTH 500
char (*styledata)[MAX_LINE_LENGTH];
styledata = new char[x][MAX_LINE_LENGTH];
which I thought was alright. I then want to copy a string into each element of the array which I have attempted to do
by accessing a pointer to that element as follows:
char *dataptr;
for (int i=0;i=y;++i)
{ dataptr = &styledata[0];
strcpy(dataptr,appropriate string);
}
This UAE's.
Been staring at it for a while now and either I'm missing the blindingly obvious, have approached the whole thing wrongly or it's kinda subtle.
Can anyone shed some light on this...
Thx for your time.