Bus Error when I run my C++ program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2005
Posts: 2
Reputation: ckrieger1 is an unknown quantity at this point 
Solved Threads: 0
ckrieger1 ckrieger1 is offline Offline
Newbie Poster

Bus Error when I run my C++ program

 
0
  #1
Apr 26th, 2005
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;
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,450
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 250
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
0
  #2
Apr 26th, 2005
>px0c0 and px0c1 are type double pointers
How's your allocation of memory to px0c0 and px0c1?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 2
Reputation: ckrieger1 is an unknown quantity at this point 
Solved Threads: 0
ckrieger1 ckrieger1 is offline Offline
Newbie Poster

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

 
0
  #3
Apr 27th, 2005
bayes.px0c0 = (double*) calloc(n, sizeof(double));
bayes.px0c1 = (double*) calloc(n, sizeof(double));

Then I have a for loop initialize all of them.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,450
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 250
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
0
  #4
Apr 28th, 2005
And n and data.n are the same? And is data.N a type for data.n?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 188
Reputation: Fasola is an unknown quantity at this point 
Solved Threads: 0
Fasola Fasola is offline Offline
Junior Poster

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

 
0
  #5
Apr 28th, 2005
what is a Bus Error?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,450
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 250
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
0
  #6
Apr 28th, 2005
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 188
Reputation: Fasola is an unknown quantity at this point 
Solved Threads: 0
Fasola Fasola is offline Offline
Junior Poster

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

 
0
  #7
Apr 28th, 2005
thanks dave
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC