/* File: big_dims.c * * Purpose: Try to change the dimension of an array * * Compile: Try * gcc -g -Wall -o dims dims.c * If this doesn't work, try * gcc -g -Wall -std=c99 -o dims dims.c * Run: ./big_dims * * Input: none * Output: messages about the arrays * * Note: * 1. A value of dim = 12 consistently causes a seg fault on one * of my MacOS X machines. You may need to experiment * with different choices of dim to get a seg fault. */ #include int main(void) { int dim = 12; int array[dim]; int i; for (i = 0; i < dim; i++) array[i] = 2*i; printf("array = "); for (i = 0; i < dim; i++) printf("%d ", array[i]); printf("\n\n"); dim *= 2; for (i = 0; i < dim; i++) array[i] = 2*i; printf("array = "); for (i = 0; i < dim; i++) printf("%d ", array[i]); printf("\n"); return 0; } /* main */