segmentation fault-- is my array too long?
Caroline Korves
ckorves at hotmail.com
Thu May 6 11:58:44 PDT 2004
Hello,
This short program below represents a problem I am having with
segmentation faults in a much larger C program that has numerous
arrays. Seems as though when I increase the number of elements in an
array (here, for example, beyond 130,000) a seg fault occurs.
Any idea on what I should change to make the program run with large
numbers of elements in my arrays?
Thanks.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define td 365 /* # days in trxn season */
#define lifetab 94 /* enter 94 lines from life
table, corresponds to 27-120 years */
/* # persons in run */
#define persons 150000
#define scens 4
int main()
{
long int j, person=0;
double ncost[persons][scens];
double nuts[persons][scens];
printf("check "); printf("\n");
for (person=0; person<persons; person++)
{
ncost[person][0]=0.00;
ncost[person][1]=0.00;
ncost[person][2]=0.00;
ncost[person][3]=0.00;
nuts[person][0]=0.00;
nuts[person][1]=0.00;
nuts[person][2]=0.00;
nuts[person][3]=0.00;
}
printf("persons "); printf("%d\n", persons);
return 0;
}
_________________________________________________________________
[1]FREE pop-up blocking with the new MSN Toolbar get it now!
References
1. http://g.msn.com/8HMAENUS/2728??PS=47575
More information about the freebsd-questions
mailing list