954,170 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Bus Error when I run my C++ program

I need help. I keep getting a Bus Error when I run my program and I've narrowed down where it occurs to the following code fragment.
px0c0 and px0c1 are type double pointers and
count_x0c0[m] and countc0 are integers. Can anyone see why this code would be giving me a Bus Error? Thanks.

// set *px0c0 and *px0c1
for(int m=0;m

ckrieger1
Newbie Poster
2 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

>px0c0 and px0c1 are type double pointers
How's your allocation of memory to px0c0 and px0c1?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

bayes.px0c0 = (double*) calloc(n, sizeof(double));
bayes.px0c1 = (double*) calloc(n, sizeof(double));

Then I have a for loop initialize all of them.

ckrieger1
Newbie Poster
2 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

And n and data.n are the same? And is data.N a type for data.n?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

what is a Bus Error?

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

thanks dave

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You