I am trying to create a function that will accept multiple arguments in a string a la printf, and send them through a socket. I feel I'm on the right track, however... I'm wondering why this isn't working. It seems that when i use more than one special character, such as %s, it starts doing the others on newlines (I need it to send through the socket as one complete string)
what am I doing wrong?
Code:
int sendraw(int socket, char *message, ...)
{
char buffer[512];
va_list args;
va_start(args, message);
vsprintf(buffer, message, args);
va_end(args);
send(socket, buffer, strlen(buffer), 0);
}