473,247 Members | 3,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,247 software developers and data experts.

Help is need immidiately

Hello all,

I need desperate help

Here is the problem:

My problem today is with multidimensional arrays.

Lets say i have an array A[31][130][256][256] this is a 4 dimensional
static array.

How will i declare this same array with same dimensions dynamically and
also after dynamic declaration i want to be able to access contents of
array with indiceslike i should be able to access an elemt after after
dynamic declarartion as
A[23][34][56][78].Is this possible

Please help

Now pls remember that memory space for the array is not a concern and i
cant change this data structure

Thanks

May 30 '06 #1
23 2480
vi************@gmail.com wrote:
Hello all,

I need desperate help

Here is the problem:

My problem today is with multidimensional arrays.

Lets say i have an array A[31][130][256][256] this is a 4 dimensional
static array.

How will i declare this same array with same dimensions dynamically and
also after dynamic declaration i want to be able to access contents of
array with indiceslike i should be able to access an elemt after after
dynamic declarartion as
A[23][34][56][78].Is this possible

Please help

Now pls remember that memory space for the array is not a concern and i
cant change this data structure


This is an FAQ question. The FAQ can be found at <http://c-faq.com/>,
your question is 6.16. If after reading the answer and trying to
implement the solution to fit your needs you have a specific question,
come back with what you have so far and a clear description of where
your problem lies.

Robert Gamble

May 30 '06 #2
In article <11**********************@g10g2000cwb.googlegroups .com>,
<vi************@gmail.com> wrote:
I need desperate help Now pls remember that memory space for the array is not a concern and i
cant change this data structure
We generally find that people when people don't leave homework
to the last minute, that they don't need desperate immediate help.

Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A[31][130][256][256] this is a 4 dimensional
static array. How will i declare this same array with same dimensions dynamically


If it is the 'same array' then it would have the same properties
of being static and with those exact fixed dimensions. It would be
a contradiction in the question to ask to allocate a static array
dynamically, or to allocate an array with exact fixed dimensions
with variable dimensions.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
May 30 '06 #3
Hi,

After reading the stuff i still have no idea as to how u would proceed
with a 4 dimensional array.I would really appreiciate it if someone who
actually knows how to assign a dynamic 4-D array in C could please help
me out.

Thanks

May 30 '06 #4
Hey,

Okay i havent written that correctly.There arent 2 arrays.I just want
to declare a dynamic array A[31][130][256][256] and access it with
indices like i would a static array.

Thanks

May 30 '06 #5


vi************@gmail.com wrote On 05/30/06 12:46,:
Hey,

Okay i havent written that correctly.There arent 2 arrays.I just want
to declare a dynamic array A[31][130][256][256] and access it with
indices like i would a static array.


SomeType (*A)[31][130][256][256];
A = malloc(sizeof *A);
if (A == NULL)
abort();
A[1][2][3][4] = 42;

--
Er*********@sun.com

May 30 '06 #6
vi************@gmail.com wrote:
Hi,

After reading the stuff i still have no idea as to how u would proceed
with a 4 dimensional array.I would really appreiciate it if someone
who actually knows how to assign a dynamic 4-D array in C could
please help me out.


Please review the .sig information at the end of this message.

What about the FAQ answer confuses you? You haven't explained why you
are having problems. What have you tried? Have you created a 2-D
dynamic array?

What do you want a dynamic array? Normally that is for when you don't
know the size of the dimensions. This problem smells like homework. You
haven't presented the overall problem, just "how do I do a dynamic 4-D
array." You haven't said WHY you want such a beast, nor have you said
what you mean by such an array.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
May 30 '06 #7
On Tue, 30 May 2006 12:50:17 -0400, Eric Sosman <Er*********@sun.com>
wrote:


vi************@gmail.com wrote On 05/30/06 12:46,:
Hey,

Okay i havent written that correctly.There arent 2 arrays.I just want
to declare a dynamic array A[31][130][256][256] and access it with
indices like i would a static array.


SomeType (*A)[31][130][256][256];
A = malloc(sizeof *A);
if (A == NULL)
abort();
A[1][2][3][4] = 42;


I'm sure you really meant
(*A)[1][2][3][4] = 42;
Remove del for email
May 31 '06 #8
this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.

Thanks,
Barry Schwarz wrote:
On Tue, 30 May 2006 12:50:17 -0400, Eric Sosman <Er*********@sun.com>
wrote:


vi************@gmail.com wrote On 05/30/06 12:46,:
Hey,

Okay i havent written that correctly.There arent 2 arrays.I just want
to declare a dynamic array A[31][130][256][256] and access it with
indices like i would a static array.


SomeType (*A)[31][130][256][256];
A = malloc(sizeof *A);
if (A == NULL)
abort();
A[1][2][3][4] = 42;


I'm sure you really meant
(*A)[1][2][3][4] = 42;
Remove del for email


May 31 '06 #9


Barry Schwarz wrote On 05/30/06 20:48,:
On Tue, 30 May 2006 12:50:17 -0400, Eric Sosman <Er*********@sun.com>
wrote:


vi************@gmail.com wrote On 05/30/06 12:46,:
Hey,

Okay i havent written that correctly.There arent 2 arrays.I just want
to declare a dynamic array A[31][130][256][256] and access it with
indices like i would a static array.


SomeType (*A)[31][130][256][256];
A = malloc(sizeof *A);
if (A == NULL)
abort();
A[1][2][3][4] = 42;

I'm sure you really meant
(*A)[1][2][3][4] = 42;


Good catch, but wrong diagnosis. What I *really*
meant was (ahem, ahem):

SomeType (*A)[130][256][256];
A = malloc(31 * sizeof *A);
if (A == NULL)
abort();
A[1][2[3][4] = 42;

(I guess you can tell who doesn't recall the last time
he used a 4D array ... Thanks for the eagle eye.)

--
Er*********@sun.com

May 31 '06 #10
In article <1149098124.334737@news1nwk>,
Eric Sosman <Er*********@sun.com> wrote:
Good catch, but wrong diagnosis. What I *really*
meant was (ahem, ahem): SomeType (*A)[130][256][256];
A = malloc(31 * sizeof *A);
if (A == NULL)
abort();
A[1][2[3][4] = 42;


missing ] in line 42 ;-)

--
All is vanity. -- Ecclesiastes
May 31 '06 #11
vi************@gmail.com writes:
this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.


Don't top-post. Read <http://www.caliburn.nl/topposting.html>.

What are you really trying to accomplish? If this is a homework
assignment, we're not going to do it for you (unless you give us your
instructor's e-mail address so we can submit the solution directly).

There should be enough information in the FAQ for you to figure out
how to solve the problem. What exactly is giving you trouble?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 31 '06 #12
On Wed, 31 May 2006 18:11:34 GMT, Keith Thompson <ks***@mib.org>
wrote:
vi************@gmail.com writes:
this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.


Don't top-post. Read <http://www.caliburn.nl/topposting.html>.

What are you really trying to accomplish? If this is a homework
assignment, we're not going to do it for you (unless you give us your
instructor's e-mail address so we can submit the solution directly).

There should be enough information in the FAQ for you to figure out
how to solve the problem. What exactly is giving you trouble?


He may have a purely academic interest in seeing how a C++ expert
might express this. I know I do - I don't know how this would be done
(chaining?), and I would quite like to see some approaches.
May 31 '06 #13
W Marsh said:
He may have a purely academic interest in seeing how a C++ expert
might express this.
I presume you mean "C expert".
I know I do - I don't know how this would be done
(chaining?), and I would quite like to see some approaches.


Well, the FAQ covers it, pretty much.

Look, let's say you want a 1-D array of T. How would you do it? Like this?

#include <stdlib.h>

#include "t.h"

T *create_T_array(size_t z)
{
T *new = malloc(z * sizeof *new);
if(new != NULL)
{
size_t i = 0;
T blank = {0};
for(i = 0; i < z; i++)
{
new[i] = blank;
}
}
return new;
}

void destroy_T_array(T **old)
{
if(old != NULL && *old != NULL)
{
free(*old);
*old = NULL;
}
}

So - how would you create an array of such arrays?

T **create_TT_array(size_t y, size_t z)
{
T **new = malloc(y * sizeof *new);
if(new != NULL)
{
size_t i = 0;
int ok = 1;
for(i = 0; ok && i < y; i++)
{
new[i] = create_T_array(z);
if(new[i] == NULL)
{
ok = 0;
while(i > 0)
{
--i;
destroy_T_array(new + i);
}
free(new);
new = NULL;
}
}
}

return new;
}

And so on and so forth. You build up from inside, creating the functions
that you will need in the "outer" layers. It's very simple.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
May 31 '06 #14
On 31 May 2006 09:41:51 -0700, vi************@gmail.com wrote:
this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.


That's not what this group is for. We'll be glad to help, but not do
your work for you. The relationship between pointers and array indexes
is very basic in C, and you should consult your textbooks. Try writing
something to do the job. If you can't make it work, post your code
here and ask for help.

If you really need someone else to do it for you, try one of the
*.sources.wanted groups.

--
Al Balmer
Sun City, AZ
May 31 '06 #15
On Wed, 31 May 2006 19:01:55 +0000, Richard Heathfield
<in*****@invalid.invalid> wrote:
W Marsh said:
He may have a purely academic interest in seeing how a C++ expert
might express this.


I presume you mean "C expert".


Haha! I thought I was reading comp.lang.c++.

I'm just going to leave now.
May 31 '06 #16
Walter Roberson wrote:
In article <1149098124.334737@news1nwk>,
Eric Sosman <Er*********@sun.com> wrote:

Good catch, but wrong diagnosis. What I *really*
meant was (ahem, ahem):


SomeType (*A)[130][256][256];
A = malloc(31 * sizeof *A);
if (A == NULL)
abort();
A[1][2[3][4] = 42;

missing ] in line 42 ;-)


<Sigh.> Some days, it just doesn't pay to get out of bed.

--
Eric Sosman
es*****@acm-dot-org.invalid
Jun 1 '06 #17
vi************@gmail.com wrote:
Barry Schwarz wrote:
On Tue, 30 May 2006 12:50:17 -0400, Eric Sosman <Er*********@sun.com>
wrote:
vi************@gmail.com wrote On 05/30/06 12:46,:
>
> Okay i havent written that correctly.There arent 2 arrays.I just want
> to declare a dynamic array A[31][130][256][256] and access it with
> indices like i would a static array.

SomeType (*A)[31][130][256][256];
A = malloc(sizeof *A);
if (A == NULL)
abort();
A[1][2][3][4] = 42;


I'm sure you really meant
(*A)[1][2][3][4] = 42;

this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.


Please don't top-post.

Now, if I understand you right, you want to allocate a block of dynamic
memory such that you can use subscripts similar to four-dimensional
arrays to access the elements of the block... ?

The following code is one way I thought of. It's very inefficient and
importantly doesn't free() the allocated memory before program exit.
However it shows how you can use pointers to allocate a block of
dynamic memory and access it's elements *as if* it were a
four-dimensional static array.

Generally a N dimensional array of pointers of type T can provide
access to a N+1 dimensional array of objects of type *T. So, to access
a block of dynamic memory as a four-dimensional array, we must allocate
a three-dimensional array of pointers of the appropriate type. This
three-dimensional array of pointers can be accessed by a
two-dimensional array of pointers-to-pointers. This can in turn be
accessed by a one-dimensional array of
pointers-to-pointers-to-pointers. This is pointed to by a single
pointer-to-a-pointer-to-a-pointer-to-a-pointer.

/* Dynamically allocating a four dimensional array and using it */
#include <stdio.h>
#include <stdlib.h>

#define ARR_SIZ 10

int main(void) {
char ****array = NULL;
int cnt, cnt1, cnt2, cnt3;

if((array = malloc(ARR_SIZ * sizeof *array)) == NULL)
return EXIT_FAILURE;
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
if((array[cnt] = malloc(ARR_SIZ * sizeof **array)) == NULL)
return EXIT_FAILURE;
}
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
if((array[cnt][cnt1] =
malloc(ARR_SIZ * sizeof ***array)) == NULL)
return EXIT_FAILURE;
}
}
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
if((array[cnt][cnt1][cnt2] =
malloc(ARR_SIZ * sizeof ****array)) ==
NULL)
return EXIT_FAILURE;
}
}
}

puts("Storing values in the array...");
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
for(cnt3 = 0; cnt3 < ARR_SIZ; ++cnt3)
array[cnt][cnt1][cnt2][cnt3] = cnt3;
}
}
}

puts("Printing out the array...");
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
for(cnt3 = 0; cnt3 < ARR_SIZ; ++cnt3) {
printf("array[%d][%d][%d][%d] = %d\n",
cnt, cnt1, cnt2, cnt3,
array[cnt][cnt1][cnt2][cnt3]);
}
}
}
}

exit(0);
}

Jun 1 '06 #18
Hey,

Thank you santosh.Its been a pleasure.Someone finally who actually
knows how to solve the problem.Brilliant mate.No condescending
remarks..no pretences of actually "knowing" how to do it.No alternate
solution.Just plain and simple code.

Thanks

santosh wrote:
vi************@gmail.com wrote:
Barry Schwarz wrote:
On Tue, 30 May 2006 12:50:17 -0400, Eric Sosman <Er*********@sun.com>
wrote:
>vi************@gmail.com wrote On 05/30/06 12:46,:
>>
>> Okay i havent written that correctly.There arent 2 arrays.I just want
>> to declare a dynamic array A[31][130][256][256] and access it with
>> indices like i would a static array.
>
> SomeType (*A)[31][130][256][256];
> A = malloc(sizeof *A);
> if (A == NULL)
> abort();
> A[1][2][3][4] = 42;

I'm sure you really meant
(*A)[1][2][3][4] = 42;

this is all good but guys i need to access the arrays like
a static array and not with pointer referencing
like i need to access A with A[][][][].Please is there someone who can
suggest a technique.there have been many qs asked as to why i need the
array ,what about the memory,FAQs i need to read.I thought i can get
some real help here.Is there no one who can actually solve the
problem.Why is there a need to give an alternate solution.I dont
require alternates.This is the problem plain and simple i have a to
declare a 4 dimensional dynamic array and need to then aces it like a
static array with normal array indices like a[][][][] and not
*A(i*j*k).I know the compiler treats it the same .But i need the access
to it through A[][][][].Please anyone.I would really appreciate a
solution then some condesecnding remarks or an alterante solution.


Please don't top-post.

Now, if I understand you right, you want to allocate a block of dynamic
memory such that you can use subscripts similar to four-dimensional
arrays to access the elements of the block... ?

The following code is one way I thought of. It's very inefficient and
importantly doesn't free() the allocated memory before program exit.
However it shows how you can use pointers to allocate a block of
dynamic memory and access it's elements *as if* it were a
four-dimensional static array.

Generally a N dimensional array of pointers of type T can provide
access to a N+1 dimensional array of objects of type *T. So, to access
a block of dynamic memory as a four-dimensional array, we must allocate
a three-dimensional array of pointers of the appropriate type. This
three-dimensional array of pointers can be accessed by a
two-dimensional array of pointers-to-pointers. This can in turn be
accessed by a one-dimensional array of
pointers-to-pointers-to-pointers. This is pointed to by a single
pointer-to-a-pointer-to-a-pointer-to-a-pointer.

/* Dynamically allocating a four dimensional array and using it */
#include <stdio.h>
#include <stdlib.h>

#define ARR_SIZ 10

int main(void) {
char ****array = NULL;
int cnt, cnt1, cnt2, cnt3;

if((array = malloc(ARR_SIZ * sizeof *array)) == NULL)
return EXIT_FAILURE;
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
if((array[cnt] = malloc(ARR_SIZ * sizeof **array)) == NULL)
return EXIT_FAILURE;
}
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
if((array[cnt][cnt1] =
malloc(ARR_SIZ * sizeof ***array)) == NULL)
return EXIT_FAILURE;
}
}
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
if((array[cnt][cnt1][cnt2] =
malloc(ARR_SIZ * sizeof ****array)) ==
NULL)
return EXIT_FAILURE;
}
}
}

puts("Storing values in the array...");
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
for(cnt3 = 0; cnt3 < ARR_SIZ; ++cnt3)
array[cnt][cnt1][cnt2][cnt3] = cnt3;
}
}
}

puts("Printing out the array...");
for(cnt = 0; cnt < ARR_SIZ; ++cnt) {
for(cnt1 = 0; cnt1 < ARR_SIZ; ++cnt1) {
for(cnt2 = 0; cnt2 < ARR_SIZ; ++cnt2) {
for(cnt3 = 0; cnt3 < ARR_SIZ; ++cnt3) {
printf("array[%d][%d][%d][%d] = %d\n",
cnt, cnt1, cnt2, cnt3,
array[cnt][cnt1][cnt2][cnt3]);
}
}
}
}

exit(0);
}


Jun 1 '06 #19
vi************@gmail.com writes:
Thank you santosh.Its been a pleasure.Someone finally who actually
knows how to solve the problem.Brilliant mate.No condescending
remarks..no pretences of actually "knowing" how to do it.No alternate
solution.Just plain and simple code.

[...]

Please stop top-posting. See <http://www.caliburn.nl/topposting.html>.

You got a lot of negative feedback on your original question. The
reason for this is that you stated a problem and demanded that we
write the code to solve it for you. We tried to point you to a
resource (the FAQ) that should have helped you solve the problem
yourself. You never explained just why you need to do this.

If this was homework, the point is for you to learn how to do it
yourself. If the rest of us are going to write all the code, why is
your participation necessary?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 1 '06 #20
On 1 Jun 2006 10:28:38 -0700, vi************@gmail.com wrote:
Thank you santosh.Its been a pleasure.Someone finally who actually
knows how to solve the problem.Brilliant mate.No condescending
remarks..no pretences of actually "knowing" how to do it.No alternate
solution.Just plain and simple code.


I expect that everyone who replied knows how to do it. However, they
apparently failed in their goal of letting you learn how to do it. Too
bad - Santosh did you a disservice, but perhaps you can hire him the
next time you need a program written.

--
Al Balmer
Sun City, AZ
Jun 1 '06 #21
Al Balmer wrote:
On 1 Jun 2006 10:28:38 -0700, vi************@gmail.com wrote:
Thank you santosh.Its been a pleasure.Someone finally who actually
knows how to solve the problem.Brilliant mate.No condescending
remarks..no pretences of actually "knowing" how to do it.No alternate
solution.Just plain and simple code.
I expect that everyone who replied knows how to do it. However, they
apparently failed in their goal of letting you learn how to do it. Too
bad - Santosh did you a disservice,...


Eh, how do come to that conclusion? Whom did I do a "disservice"? The
OP? Well, if he's intelligent and serious about programming, he'll
study my code, (and other material), and figure it out himself. If he's
not and he uses my code, as such, for his project, then that's his
descision and problem. He'll come a cropper someday or the other.
Either way, I don't consider my post a "disservice". Depending on what
the OP does with it, he'll create his own advantage or "disservice" for
himself.

Following your line of thought, guns should be banned in the US
because, *some* angsty kid decides to test the trigger. Or all source
code should be removed from the internet, because people like the OP
may allegedly use it to further their mis-education. Further, pete will
be heartened to hear that you consider his contributions to the group a
"disservice".
but perhaps you can hire him the next time you need a program written.


No need to insult me just because the OP happened to criticise the
group.

Jun 1 '06 #22
vi************@gmail.com wrote:
vi************@gmail.com wrote: .... snip ...> this is all good but guys i need to access the arrays like
> a static array and not with pointer referencing
.... snip ... santosh wrote:
Please don't top-post.

Now, if I understand you right, you want to allocate a block of dynamic
memory such that you can use subscripts similar to four-dimensional
arrays to access the elements of the block... ?

The following code is one way I thought of. It's very inefficient and
importantly doesn't free() the allocated memory before program exit.
.... snip ...
Hey,

Thank you santosh.Its been a pleasure.Someone finally who actually
knows how to solve the problem.Brilliant mate.No condescending
remarks..no pretences of actually "knowing" how to do it.No alternate
solution.Just plain and simple code.

Thanks


No problem but generally the regulars of this group are *far* more well
versed in C than you or me. In my short time here, I've learned quite a
bit about writing good C code that would otherwise have been learnt
much slower, if my only sources had been books and tutorials.

As for your question, the FAQ entry, (reffered to you in the first
reply to your post), actually has enough pointers, (pardon the pun) to
enable you to figure it out yourself. I'll admit that multidimensional
arrays and pointers are not the easiest aspects of C, but generally
they can be tackled if you proceed systematically from the fundamental
concepts and syntax, trying out progressively more complex demos
yourself.

Jun 1 '06 #23
On 1 Jun 2006 12:28:26 -0700, "santosh" <sa*********@gmail.com> wrote:
Al Balmer wrote:
On 1 Jun 2006 10:28:38 -0700, vi************@gmail.com wrote:
>Thank you santosh.Its been a pleasure.Someone finally who actually
>knows how to solve the problem.Brilliant mate.No condescending
>remarks..no pretences of actually "knowing" how to do it.No alternate
>solution.Just plain and simple code.
I expect that everyone who replied knows how to do it. However, they
apparently failed in their goal of letting you learn how to do it. Too
bad - Santosh did you a disservice,...


Eh, how do come to that conclusion? Whom did I do a "disservice"? The
OP? Well, if he's intelligent and serious about programming, he'll
study my code, (and other material), and figure it out himself.


No, he won't. (Witholding judgment on his intelligence and
seriousness.) Why should he, when he can get someone else to do it?
If he's
not and he uses my code, as such, for his project, then that's his
descision and problem. He'll come a cropper someday or the other.
Either way, I don't consider my post a "disservice". Depending on what
the OP does with it, he'll create his own advantage or "disservice" for
himself.

Following your line of thought, guns should be banned in the US
because, *some* angsty kid decides to test the trigger.
Huh? Are you saying that kids should not be encouraged to learn how to
handle a gun, but should always depend on someone else to do it for
them? That's a different issue, and perhaps you think that's the case,
but that's not the practice here wrt learning C. We try to help people
learn, rather than doing their work for them. As I pointed out, if the
OP wants someone to do the work for him, there are other venues.
Or all source
code should be removed from the internet, because people like the OP
may allegedly use it to further their mis-education.
Huh? Again. I would encourage the OP to study and use other people's
sources. If he has difficulty understanding it, he can ask for help
here. But that has nothing to do with insisting that someone else do
his work and refusing even to try doing it himself.
Further, pete will
be heartened to hear that you consider his contributions to the group a
"disservice".

Huh? Once again. Who's Pete?
but perhaps you can hire him the next time you need a program written.


No need to insult me just because the OP happened to criticise the
group.


Four for four. How on earth did you detect an insult in that? I
certainly wouldn't suggest it if I didn't think you were competent.

--
Al Balmer
Sun City, AZ
Jun 1 '06 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve Teeples | last post by:
Can someone point me to a document that clearly identifies the steps of creating a good help system for an application? I have a test tool that I'd like to add help to so that others will know how...
17
by: homepricemaps | last post by:
hey folks, have a logic question for you. appreciate the help in advance. i am scraping 3 pieces of information from the html namely the food name , store name and price. and i am doing this...
3
by: andy | last post by:
I am starting a new application, it needs to use db such as access or msde. I know I can do this easily in c# or Java but my question is can I distribute a package as easy if it is created with...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.