Date: Thu, 06 May 2004 14:58:43 -0400 From: "Caroline Korves" <ckorves@hotmail.com> To: freebsd-questions@freebsd.org Subject: segmentation fault-- is my array too long? Message-ID: <BAY8-F110nFxZmS40m300006fb4@hotmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BAY8-F110nFxZmS40m300006fb4>
