Question on large arrays in C

jwp at uwmacc.UUCP jwp at uwmacc.UUCP
Thu Feb 12 10:46:15 AEST 1987


I am running 4.3BSD on a MicroVax II.
I have a simple program:

----------
#include <stdio.h>
#define N 20480
main()
{
	double x[N];
	double y_1[N];
	double y_2[N];
	double y_3[N];
	double y_4[N];
	char *l = "";

	fprintf(stdout, "hi\n");
	exit(0);
}
----------

When I run it, I get "Segmentation violation".
dbx reports the violation to occur on the "char *l" line.
If I move the 5 array declarations up above main(),
under the define statement, the program works OK.
What is wrong with the program as listed above?
-- 
	Jeff Percival ...!uwvax!uwmacc!sal70!jwp or ...!uwmacc!jwp



More information about the Comp.unix.questions mailing list