hi there. i am new to C++ AND unix. this assignment that i have is really really easy, but the specifics of C++ and getting around in Unix is making it really hard and time consuming. i have a really small program that should be working, but i am getting the wrong output AND at the end of the output i get a Segmentation fault.
i have a function called series that is declared and works fine. i have inserted a cout<< to check that the function is working right. but i am still getting the wrong output AND this error. am i doing something illegal? using the function result as the array index? i know i am not telling you much about the code, i am just wondering if there are any GLARING unix or C++ no-nos that anyone sees.
int main (){
const int MAX_NUM = 60;
const int MAX_CALLS = 41;
int num_calls [MAX_CALLS];
int k = 0;
for(int i=1; i<=MAX_NUM; i++){
num_calls[i] = 0;
cout<< series(i) <<endl;
if ((series (i)) < MAX_CALLS){
num_calls[series (i)]++;
}
else{
k++;
}
}
for(int l=1; l<MAX_CALLS; l++){
cout<< l << " " << num_calls[l] <<endl;
}
cout<< "and " << k << "numbers have series length greater than 40" <<endl;
}
thanks
crq