|
-
May 30th, 2001, 10:26 AM
#1
Thread Starter
Frenzied Member
Dynamic Array
I know that this has been asked before, at least by me once, but since the SEARCH DOESNT WORK!!, I cant find it.
How can you dynamicly create arrays?
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
May 30th, 2001, 10:55 AM
#2
Frenzied Member
How to create a dynamic array in C (Don't know if you can use that...): http://cplus.about.com/cs/advancedc/...namic+Arrays+C
-
May 30th, 2001, 12:30 PM
#3
Frenzied Member
Code:
//c++
int *ar = new int[value];
delete ar;
//c
char *string;
string = malloc(value);
free( string );
-
May 30th, 2001, 12:30 PM
#4
Monday Morning Lunatic
C and C++ use different methods. If you're using C++, then you want new:
Code:
int *piArray = new int[50];
delete[] piArray;
C:
Code:
int *piArray = (int*)malloc(50 * sizeof(int));
free(piArray);
In C++, if you actually want a dynamic array, use the STL vector class.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 30th, 2001, 03:12 PM
#5
You could also use a linked list.
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
|