Why does the program crash when it enters a function?
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
How are you calling this function?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
If it's crashing at the point you mentioned, it's because it is unable to successfully process the parameters. Check David Crow's comments, I think he is probably right. Also, I am not sure, but check your syntax. I am not sure if I remember correctly, but when I learned C++, I was taught that you typically pass in an array as one parameter, and the subscripts as additional parameters - or something like that, I am not sure. Anyway, you may want to use vectors instead. I hope this helps. Peace, BP
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
KaKa' wrote:
nt rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples])
change it to int rank(int num,const int **data,const double *dist,const double * rank,int Tuples,int feature)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
How do you use this function?
_**
**_
WhiteSky
-
Hi, I am writing a C++ program. I have found out that an unhandled exception message will pop out whenever the code enters a function. I have used breakpoints and cout statements to determine the point of the crash. The function has 4 parameters. 1 int variable, 1 int array and 2 double arrays. "Tuples" and "Features" are constants representing values of 1600 and 46 respectively. int rank(int num,int data[Tuples][Features], double dist[Tuples],double rank[Tuples]) { .......... ...........} The program crashes after the first opening bracket. '{'. None of the statements inside the function are executed. I don't know what is going on. How come the program will crash without even executing a statement?
Hi,thanks all for the replies. I think it could be a stack overflow because previously the 2D array was 128 rows by 46 columns but when I expanded it to 1600 rows, the program crashed. So, if the the function parameters are replaced by pointers instead of arrays, will the crash problem be solved? I call the rank function using this: rank(n,d,distance,r); where n is the integer variable, d is the 2D array while distance and r are the 1D arrays.