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?
Printable View
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?
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
Code://c++
int *ar = new int[value];
delete ar;
//c
char *string;
string = malloc(value);
free( string );
C and C++ use different methods. If you're using C++, then you want new:
C:Code:int *piArray = new int[50];
delete[] piArray;
In C++, if you actually want a dynamic array, use the STL vector class.Code:int *piArray = (int*)malloc(50 * sizeof(int));
free(piArray);
You could also use a linked list.