944,021 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 25433
  • C++ RSS
Apr 26th, 2005
0

Bus Error when I run my C++ program

Expand Post »
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<data.n;m++)
{
bayes.px0c0[m]=1.0 * (count_x0c0[m]/countc0);
bayes.px0c1[m]=1.0 * (count_x0c1[m]/countc1);
}

bayes.pc0 = 1.0 * countc0 / data.N;
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ckrieger1 is offline Offline
2 posts
since Apr 2005
Apr 26th, 2005
0

Re: Bus Error when I run my C++ program

>px0c0 and px0c1 are type double pointers
How's your allocation of memory to px0c0 and px0c1?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Apr 27th, 2005
0

Re: Bus Error when I run my C++ program

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

Then I have a for loop initialize all of them.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ckrieger1 is offline Offline
2 posts
since Apr 2005
Apr 28th, 2005
0

Re: Bus Error when I run my C++ program

And n and data.n are the same? And is data.N a type for data.n?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Apr 28th, 2005
0

Re: Bus Error when I run my C++ program

what is a Bus Error?
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005
Apr 28th, 2005
0

Re: Bus Error when I run my C++ program

Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Apr 28th, 2005
0

Re: Bus Error when I run my C++ program

thanks dave
Reputation Points: 11
Solved Threads: 0
Junior Poster
Fasola is offline Offline
188 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: How to read end of line?
Next Thread in C++ Forum Timeline: passing a vector to a function? :errors:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC