473,395 Members | 1,999 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,395 software developers and data experts.

How can I increment/decrement a multidemensional array without a loop?

Hi, I would like to pick four elements from a multidemensional array
and use the content of those elements. I want to do this without all
the subscript calls required for individual access, just want this for
speed. I know you can increment regular arrays via ++array or array++
etc. etc. but how do you do it with multidemensional arrays? lets say
I have array[x][y] and I need to access array[x+1][y+1] how can I do
this without the subscripts? The x and y count is at 64 by the way.

Thanks for any help.
Jul 19 '05 #1
1 5942
"Hendrix" <dr*******@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
Hi, I would like to pick four elements from a multidemensional array
and use the content of those elements. I want to do this without all
the subscript calls required for individual access, just want this for
speed. I know you can increment regular arrays via ++array or array++
etc. etc. but how do you do it with multidemensional arrays? lets say
I have array[x][y] and I need to access array[x+1][y+1] how can I do
this without the subscripts? The x and y count is at 64 by the way.


It's as simple as:
itemPtr += (rowLen+1);
Or in the case you mention:
itemPtr += 65;
Assuming that itemPtr points within: Item dataArray[64][64]; and
is in-range.

Note that, when starting to fiddle with item address calculations
in multi-dimensional arrays, I would recommend using a 1-dimensional
array and doing all offset calculations manually. While IIRC the
sub-arrays are supposed to be contiguous, using a consistent
approach should be preferred IMO.

hth,
--
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Soft Dev Manger, XiTact <> http://www.xitact.com
Brainbench MVP for C++ <> http://www.brainbench.com
Jul 19 '05 #2

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

Similar topics

4
by: Red | last post by:
I have an array which is dynamically generated by parsing a web page: titles Array ( => bookmarks => New Folder => New Folder2 ) and I want to insert html links into another,...
1
by: Elementary Penguin | last post by:
is there a way to decrement a foreach loop? for example string s = "cat"; foreach(char c in s) //some how it goes backward here Console.WriteLine(c);
9
by: Mark Turney | last post by:
I was reading "Practical C++ Programming" yesterday, and it mentioned that the order of execution for post-increment and post-decrement operators was ambiguous. I had previously learned that a...
8
by: lovecreatesbeauty | last post by:
Hello experts, Why can this difference between prefix increment/decrement and postfix increment/decrement reside in built-in operators for built-in data types? Thanks. // test.cpp // //...
3
by: George Ter-Saakov | last post by:
What is the purpose of having Interlocked.Increment if it does not work with variable declared as volatile. Here is my problem, Interlocked.Increment increments the variable in thread safe...
5
by: Stuart | last post by:
Hi all, Iv'e got a page that has a mass amount of input fields, all of which require a decimal figure. To make it easier when it comes to inputting data, I'm trying to setup + and - links that...
2
by: Perseus | last post by:
Hi To split a single string we do the following # myString= "bannana, bowling balls, juice" string singleArray= myString.split(','); # This gives singleArray = "bannana" etc.
6
by: Kevin Walzer | last post by:
This code: #include <stdio.h> int main(void) { int n1, n2; //two integers n1 = 1; n2 = 1;
3
by: Stang1 | last post by:
The following statement: line_buf = ' '; is equivalent to: line_buf = ' '; line_len++;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.