long int d[500], i;
d[1] = 1;
d[2] = 2;
d[3] = 4;
for(i = 4; i<=500; i++)
d[i] = d[i-1] + d[i-2] + d[i-3];
int n = 500;
printf("%ld\n", d[500]);
The compiler is gcc. Bus error occurred at compiling. What caused this to happen?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
long int d[500]declares an array with 500 items indexed from0to499d[500]is outside the bounds of your array.