I would like to write a C-program that allocates 20,000 memory lines with each line containing 8 bytes and are labeled in the range 2500 to 24999.. The program actually simulates a simple assembly language IDE. All the 20,000 memory lines may or may not be used at once. Suggest me how to allocate memory for those locations in the C program. Should it be a static allocation? Visit http://screencast.com/t/69T7u0avH
Try
unsigned char (*ptrtomem)[8];
unsigned char (*ptr)[8];
/* ... */
ptrtomem = malloc(20000*8);
ptr = ptrtomem-2500;
/* use ptr[2500][] to ptr[24999][] */
/* when done */
free(ptrtomem);
or use _alloca() (or alloca() depending on compiler) if you want to allocate off the stack.