-
November 17th, 2010, 12:41 PM
#1
[RESOLVED] The code compiles and has output successfully but segmentation fault
The contents are deleteted
Last edited by gracinda710; December 5th, 2010 at 12:57 PM.
-
November 17th, 2010, 12:46 PM
#2
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
-
November 17th, 2010, 01:00 PM
#3
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).
-
November 17th, 2010, 01:07 PM
#4
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.
-
November 17th, 2010, 01:11 PM
#5
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?
-
November 17th, 2010, 01:24 PM
#6
Re: The code compiles and has output successfully but segmentation fault
Yep. Arrays are indexed from 0 to size-1.
Viggy
-
November 17th, 2010, 01:26 PM
#7
Re: The code compiles and has output successfully but segmentation fault
-
November 18th, 2010, 04:16 AM
#8
Re: The code compiles and has output successfully but segmentation fault
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
-
November 18th, 2010, 07:22 AM
#9
Re: The code compiles and has output successfully but segmentation fault
Originally Posted by Morbane
you type the code tags in yourself
You can also hightlight the code and press the (somewhat unintuitive) '#' button.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|