What am I doing wrong?

Reply

Join Date: Oct 2005
Posts: 27
Reputation: calcop is an unknown quantity at this point 
Solved Threads: 0
calcop calcop is offline Offline
Light Poster

What am I doing wrong?

 
0
  #1
Oct 28th, 2005
My darn code keeps crashing, what am I doing wrong? I have a class with the follwoing method:

  1. void BBSNode::AddToBuffer(char *buffer) {
  2. //strcat((char*)inputBuffer, (char*)buffer);
  3. sprintf("Got Data: %s\n", buffer);
  4. }

I'm calling the method like this:
  1. nodes[nodeID].AddToBuffer(sockBuffer);

sockBuffer was declared like ...
  1. char sockBuffer[IN_BUFFER_SIZE];

Now, when I run the program and it calls AddToBuffer it crashes with a Bus error.

How am I calling this method wrong?

I'm using XCode 2.0

Thanks!
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 27
Reputation: calcop is an unknown quantity at this point 
Solved Threads: 0
calcop calcop is offline Offline
Light Poster

Re: What am I doing wrong?

 
0
  #2
Oct 28th, 2005
I am retarted.

I realized I was using sprintf, not printf.

Duh! Thanks for your views everyone.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1463
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: What am I doing wrong?

 
0
  #3
Oct 28th, 2005
sprintf("Got Data: %s\n", buffer);
The above is wrong. Was it just a posting error or is it really like that in your program ?
sprintf(InputBuffer, "Got Data: %s\n", buffer);
or
  1. strcpy(InputBuffer,"Got Data: ");
  2. strcat(InputBuffer,buffer);
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 27
Reputation: calcop is an unknown quantity at this point 
Solved Threads: 0
calcop calcop is offline Offline
Light Poster

Re: What am I doing wrong?

 
0
  #4
Oct 28th, 2005
I ment to do: printf, not sprintf.

Thanks.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC