Subj : Re: Questions about large memory allocation...? To : borland.public.cpp.borlandcpp From : Ed Mulroy Date : Tue Sep 13 2005 05:18 pm I have confirmed your results using Compact Model and Turbo C (don't have BC++ 5.02 on this machine). When I built it as 32 bit using C++ Builder the results counted up from zero as you wanted. Other than adding the missing includes of conio.h and stdio.h and adding the required return 0; at the end, what I ran is identical to what you posted. I don't know why it is doing this and am pressed for time right now. I'll get back to it tonight and see if I can figure out what is happening. Note that in C a cast on the return value of malloc gives no benefit and in some circumstances can hurt. Also note that the use of 'far' in the pointer declaration when building in Compact Model is redundant. The default data pointer size already is far in Compact Model. .. Ed > mujeebrm wrote in message > news:4327195f@newsgroups.borland.com... > /* prac.c, compact memory model used , bc 5.02, win xp, > > how can i allocate more than 70000 and show it printed 0 to 69999 > */ > > #include > > main() > { > unsigned int *p=0,n=0; /* compact memory model used : pointer auto > coverted > > to unsigned int far *p=0 */ > > p = (unsigned int *) malloc(65535*sizeof(unsigned int ) ); /* this works > */ > if(!p) > { > puts("out a memory!"); > exit(1); > } > printf("%p", p); > > for(n=0;n<65535;n++) > *(p+n) = n; > > for(n=0; n<65535; n++) > printf(" %u\n ", *(p+n) ); /* it doesnt show count from 0 but 32768 > onwards, > > why, as such, i want it to start at 0 onwards */ > > > free(p); > > getch(); > > } .