R
rajkumar
please see the faq section on multi-dimensional array
Raj
Raj
Hi
A question about array of pointers.
Is the following an 21 element array, each a pointer
or is this a pointer to ONE array (strange as it sounds)
double* ydata[21];
And supposing this to be 21 pointers how do I initialize
them to point to null ? Is this wrong:
for i=0; i=20 i++
ydata = NULL;
and to allocate new somewhere later
for i=0; i=20 i++
ydata = new double[1000];
This used to work in C but doesn't with C++ !
After allocating new I try this:
for (int i = 0; i < 1000; i++) {
ydata[0] = double(rev_data);
At it just crashes.
Alf said:* Henrietta Denoue:double* ydata[21];And supposing this to be 21 pointers how do I initialize
them to point to null ? Is this wrong:
for i=0; i=20 i++
ydata = NULL;
Yes, that is wrong, both syntactically (it's not C++) and in intent.
After allocating new I try this:
for (int i = 0; i < 1000; i++) {
ydata[0] = double(rev_data);
At it just crashes.
Compare that loop to the previous ones.
Henrietta Denoue said:Hi
A question about array of pointers.
Is the following an 21 element array, each a pointer
or is this a pointer to ONE array (strange as it sounds):
double* ydata[21];
And supposing this to be 21 pointers how do I initialize
them to point to null ? Is this wrong:
for i=0; i=20 i++
ydata = NULL;
and to allocate new somewhere later
for i=0; i=20 i++
ydata = new double[1000];
This used to work in C but doesn't with C++ !
After allocating new I try this:
for (int i = 0; i < 1000; i++) {
ydata[0] = double(rev_data);
At it just crashes.
Thaks for your help
Kamran
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.