473,545 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help is need immidiately

Hello all,

I need desperate help

Here is the problem:

My problem today is with multidimensiona l 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 2509
vi************@ gmail.com wrote:
Hello all,

I need desperate help

Here is the problem:

My problem today is with multidimensiona l 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************ **********@g10g 2000cwb.googleg roups.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 multidimensiona l 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*********@su n.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*********@su n.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*********@su n.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

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

Similar topics

4
2742
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 storing products in
5
2127
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=' in '*this = CTest::operator+(CTest&)((+t2))' test2.cpp:49: error: candidates are: CTest CTest::operator=(CTest&) make: *** Error 1
8
3366
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 problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if...
9
4337
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 predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user...
7
5347
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 from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not...
5
3368
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 to use it. -- Steve
17
1376
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 for many different food items found ni the html including pizza, burgers, fries etc. what i want is to write out to a text file in the following...
3
3391
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 java and say derby db as I can with windows based. It needs to be click to install and thats it, no exceptions. To date I have done this with vb...
10
3338
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 the worst I ever seen. I almost cannot find anything I need, including things I
0
7926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.