0

My darn code keeps crashing, what am I doing wrong? I have a class with the follwoing method:

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

I'm calling the method like this:

nodes[nodeID].AddToBuffer(sockBuffer);

sockBuffer was declared like ...

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!

2
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by calcop
0

I am retarted.

I realized I was using sprintf, not printf.

Duh! :) Thanks for your views everyone.

0

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

strcpy(InputBuffer,"Got Data: ");
strcat(InputBuffer,buffer);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.