[RESOLVED] The code compiles and has output successfully but segmentation fault
The contents are deleteted
Re: The code compiles and has output successfully but segmentation fault
Please use code tags. This is all but unreadable.
What is "DislinInit"? What is "DislinTwoPlots"? What is "DislinFinish"?
Take a closer look at this:
Code:
double* fit=new double[N];
for(int i=0; i<=N;i++)
fit[i]=(p[2]*xdata[i]+p[1])*xdata[i]+p[0];
Viggy
Re: The code compiles and has output successfully but segmentation fault
Sorry, i am very new to C++. The "Dislin" stuffs are actually a package using for plotting the graph, I have no idea how it works but was told to put them in the codes. I am sorry if the code is unreadable but I couldn't find the code tag buttom (if there is any).
Re: The code compiles and has output successfully but segmentation fault
Just to clarify what Viggy said, since you're very new, fit[N] isn't valid.
Re: The code compiles and has output successfully but segmentation fault
I think I should put i<N instead of i<=N, am I right?
Re: The code compiles and has output successfully but segmentation fault
Yep. Arrays are indexed from 0 to size-1.
Viggy
Re: The code compiles and has output successfully but segmentation fault
Re: The code compiles and has output successfully but segmentation fault
Quote:
Originally Posted by
gracinda710
I am sorry if the code is unreadable but I couldn't find the code tag buttom (if there is any).
you type the code tags in yourself:
[ code ]
//code . . . .
[ / code ]
Without the spaces look through this as well, cool stuff in there.... http://www.codeguru.com/forum/misc.php?do=bbcode#code
Re: The code compiles and has output successfully but segmentation fault
Quote:
Originally Posted by
Morbane
you type the code tags in yourself
You can also hightlight the code and press the (somewhat unintuitive) '#' button.