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

matrix memory allocation

Is it possible to allocate dinamically memory for a bidimensional array?
Jun 12 '06 #1
5 5553

acab wrote:
Is it possible to allocate dinamically memory for a bidimensional array?


Yes.

Homework.

Tom

Jun 12 '06 #2
acab said:
Is it possible to allocate dinamically memory for a bidimensional array?


In your dutifully careful perusal of the FAQ, you unaccountably appear to
have overlooked the following:

<http://c-faq.com/aryptr/dynmuldimary.html>

--
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)
Jun 12 '06 #3
In article <JM********************@twister1.libero.it>,
acab <pi************@yahooDOT.com> wrote:
Is it possible to allocate dinamically memory for a bidimensional array?


Yes.
Oh, you wanted to know how?

You can either allocate a single array of m*n values and calculate
the index into that array from the row and column index, or allocate m
arrays of n values plus an array of m pointers and index using the row
and column indices separately.
(Setting things up so that you can use either of these methods is left
as a (fairly simple) exercise.)
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca

If being concerned with accuracy makes me a jerk, I plead guilty.
--Richard Heathfield in comp.lang.c
Jun 12 '06 #4
Richard Heathfield wrote:
acab said:

Is it possible to allocate dinamically memory for a bidimensional array?

In your dutifully careful perusal of the FAQ, you unaccountably appear to
have overlooked the following:

<http://c-faq.com/aryptr/dynmuldimary.html>


I'll be careful next time,
thanks for helping!
Jun 12 '06 #5
On 2006-06-12, Dave Vandervies <dj******@caffeine.csclub.uwaterloo.ca> wrote:
In article <JM********************@twister1.libero.it>,
acab <pi************@yahooDOT.com> wrote:
Is it possible to allocate dinamically memory for a bidimensional array?


Yes.
Oh, you wanted to know how?

You can either allocate a single array of m*n values and calculate
the index into that array from the row and column index, or allocate m
arrays of n values plus an array of m pointers and index using the row
and column indices separately.


You can also assign the result of a single malloc to a "pointer to
array" type and use a[i][j] syntax to access the members. This is in the
FAQ as well so I won't go into it.
Jun 12 '06 #6

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

Similar topics

14
by: Wei-Chao Hsu | last post by:
There is an error in my program. The error message is e:\test\test\main.cpp(9): error C2664: 'fun' : cannot convert parameter 1 from 'int ' to 'int ** ' If I change the argument "int** a" to...
13
by: Charulatha Kalluri | last post by:
Hi, I'm implementing a Matrix class, as part of a project. This is the interface I've designed: class Matrix( )
4
by: Yudan Yi | last post by:
I have a problem to copy (assign) a matrix to another matrix. Curreny, I know copy the number using loops, while it will take some time, I wonder if there have faster method. The following code...
16
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is...
6
by: kilter | last post by:
Anyone know of a routine that will return the number of rows and columns in a matrix?
20
by: Frank-O | last post by:
Hi , Recently I have been commited to the task of "translating" some complex statistical algorithms from Matlab to C++. The goal is to be three times as fast as matlab ( the latest) . I've...
4
by: Mark | last post by:
hi, I need some help declaring a matrix of pointers. I made an image to illustrate what I had in mind... http://www.sfu.ca/~mnb2/matrix.gif and here's the relevant code I'm working with...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
3
by: teams | last post by:
Can You tell me, the alogarithm of multiply n add matrix with "malloc" or "memory allocation" ??....please help me...:(
2
by: DarrenWeber | last post by:
Below is a module (matrix.py) with a class to implement some basic matrix operations on a 2D list. Some things puzzle me about the best way to do this (please don't refer to scipy, numpy and...
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
0
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...
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
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...
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,...
0
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...
0
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...

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.