Mail Archives: djgpp/1994/11/20/22:24:32
> Want to see a BIG program? Here it is:
>
>
>char Map[256][512];
>
>int main() {
>
> memset(CellMap,0,sizeof(CellMap));
>}
>
>
> The exe it makes is about 156k. Anybody know how to tell memset that I
>really want it to run at RUN TIME? It "optimizes" itself even with
>optimizations off.
If you want your array to be allocated dynamically, you can't declare it as
allocated statically. You need code like this:
char **CellMap;
int main() {
int i;
CellMap=malloc(256 * sizeof(char *));
CellMap[0]=malloc(256 * 512); /* so we can set it to 0 in 1 swell foop */
for(i=1; i<256; i++) CellMap[i]=CellMap[i-1]+512;
memset(CellMap,0,256*512);
}
Note: this code was typed on the spot and has not been tested, so it may need
to be altered.
--- Aaron Ucko (ucko AT vax1 DOT rockhurst DOT edu; finger for PGP public key) -=- httyp!
-=*=-Just because you're paranoid doesn't mean they aren't out to get you.-=*=-
Geek code 2.1 [finger hayden AT vax1 DOT mankato DOT msus DOT edu for explanation]:
GCS/M/S d(-) H s g+ p? !au a-- w+ v+ C++(+++)>++++ U-(S+)>++++ P+ L>++ 3(-)
E-(----) !N>++ K- W(--) M-(--) V(--) po-(--) Y+(++) t(+) !5 j R G tv--(-)
b+++ !D(--) B--(---) e>++++(*) u++(@) h!() f(+) r-(--)>+++ n+(-) y?
- Raw text -