|
|
back to boardCrash (access violation) on test 9 #include <iostream> #include <stdio.h> #include <math.h> using namespace std; int main(){ double a[100000]; long long n,i=0; while (scanf("%I64d", &n) != EOF) { a[i] = sqrt((double)n); i++; } for (int x=i-1;x>=0;x--) printf("%0.4f\n",a[x]); return 0; } If I put range of array to 300000, i have "Crash (stack overflow)" on first test. What's wrong? P.S Sorry for my bad English Re: Crash (access violation) on test 9 Posted by Kit 23 Feb 2007 23:19 All variables inside functions is a dynamical variables, they always located in stack. By default stack is quite small. To avoid stack overflow move your array outside main function: double a[1000000]; int main() { } You can also increase stack size, for that see help on C++. P.S. Sorry for bad english too :) Re: Crash (access violation) on test 9 Thank you very much |
|
|