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:


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


I am retarted.

I realized I was using sprintf, not printf.

Duh! :) Thanks for your views everyone.

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);


strcpy(InputBuffer,"Got Data: ");

I ment to do: printf, not sprintf.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.