Turbo C is a very old DOS compiler.
250*250 just happens to be very near the maximum value for a 16 bit unsigned int which is what under DOS is used as a pointer.
Use a 32 bit compiler if you want to allocate larger arrays.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
why can't you use another compiler?
Cost can't be an issue as there are several modern compilers available free of charge.
Or are you stuck on a machine running DOS?
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
is there no procedure wherein you can allocate memory by malloc etc..
Yes. What have you tried?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
i am using Turbo C 3.0, when you say another compiler, what do you mean,
can you name some good free downloadable ones..
http://www.compilers.net/
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Maybe this will be the repartee, try char instead of int, very old code, but it is Turbo C ...
[php]
/******************** fararray.c ***********************
**
** Examination of the limits of global variables:
** Behaviour of two large arrays exceeding the 64k limit.
** one far global array + one local array
** Written in Turbo C V.2.0 by dns 6/15/89
**
********************************************************/
#define ASIZE 17000
int far array1[ASIZE]; /* put array far, to next 64k segment */
/*
The two arrays combined exceed 64k bytes memory, array1 is global,
array2 is local, but array1 is loaded into its own 64k segment,
so there is no interference.
If array1 exceeds 64k space itself, use huge instead of far.
*/
int main(void)
{
unsigned int array2[ASIZE];
int k;
for (k = 0; k < ASIZE; k++) /* load array1 with 0 to ASIZE */
array1[k] = k;
for (k = 0; k < ASIZE; k++) /* load array2 30000 to 30000+ASIZE */
array2[k] = k + 30000;
printf("last 100 values of array1 (16900 - 16999) =\n");
for (k = (ASIZE-100); k < ASIZE; k++)
printf("%8u",array1[k]);
printf("\n\nfirst 100 values of array2 (30000 - 30099) =\n");
for (k = 0; k < 100; k++)
printf("%8u",array2[k]);
getchar();
return 0;
}
[/php]
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417