473,699 Members | 2,440 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 2535
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
2755
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
2144
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
3383
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 the Java method is called just once and then the page is refreshed. FireFox does not crash at all...
9
4351
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 for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
7
5375
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 most, keywords. Is there any way I can activate these "missing" help topics? HELP!
5
3380
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
1404
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 order: pizza, pizza hut, 3.00
3
3398
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 and c++ with access and have had excellent success. I really want to make the transistion to java...
10
3359
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
8703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8935
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
5879
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4389
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3069
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
2
2359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.