int size = 256; //<-- Can be whatever you need (doesn't have to be a hard coded constant, could be some variable that's evaluated at run time) //Using malloc/free int *iArray; iArray = (int *) malloc(size*sizeof(int)); //Allocate (requires size in bytes, hence the sizeof() call) //To check if valid and take appropriate action if(iArray == NULL) { printf("Error: Failed to allocated required memory."); exit(1); } //... Use free(iArray); //Deallocate when done
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)