|
-
October 29th, 2001, 07:22 AM
#1
Allocation memory ?
How to allocate memory for 2-dimension array at run time ?
-
October 29th, 2001, 07:44 AM
#2
Re: Allocation memory ?
Think carefully before you answer this question: How many dimensions must be dynamic at runtime?
If the number of columns is fixed, while the number of row must vary (which is the case about 95% of the time), the answer is fairly simple.
If both the number of rows and the number of columns must vary, it's a lot more difficult.
Truth,
James
http://www.NJTheater.com
http://www.NovelTheory.com
I don't do it for the points (OK, maybe I do), but rating a post is a good way for me to know if I helped.
-
October 30th, 2001, 07:22 PM
#3
Re: Allocation memory ?
How about
int **array
int nRows=5;
int nCols=3;
array= new int*[nRows];
for ( int index = 0; index < nRows; index++ )
{
array[index] = new int[nCols];
}
Now is this what you were looking for?
Share what you know and ask what you dont....
Using Java version on windows 1.8_51
-
October 31st, 2001, 12:40 AM
#4
Re: Allocation memory ?
Yes Saeed, I want to ask same thing but in different way. I do not want to specify any size of an array.
Suppose I have 'n' values to insert to an array, now at run time, program should automatically expand the size of an array and store new value.
-
October 31st, 2001, 04:27 PM
#5
Re: Allocation memory ?
You are better off looking at link lists
i suggest you look at
http://www.codeguru.com/cgi-bin/bbs/...&Number=296877
Share what you know and ask what you dont....
Using Java version on windows 1.8_51
-
October 31st, 2001, 05:22 PM
#6
Re: Allocation memory ?
You don't give us any detail so I won't give you any :-) but if the standard C++ library doesn't have something for you (list, array, vector, etc.) then I'll go heave. Focusing on allocating memory worries me, are you sure you're thinking in C++ and not C? 
-
November 1st, 2001, 07:31 AM
#7
Re: Allocation memory ?
THANKS for your KIND HELP.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|