c - Are memory addresses in assembly language statically allocated at once? -
i write c-program allocates 20,000 memory lines each line containing 8 bytes , labeled in range 2500 24999.. program simulates simple assembly language ide. 20,000 memory lines may or may not used @ once. suggest me how allocate memory locations in c program. should 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][] ptr[24999][] */ /* when done */ free(ptrtomem);
or use _alloca() (or alloca() depending on compiler) if want allocate off stack.
Comments
Post a Comment