putting a numeric value into an array of chars?
hi, i'm sending a socket message with the format
Code:
char comm // command. 1 byte
ushort size // size of following data. 2 bytes
char data[size] // miscellaneous data. size bytes
// i try to put it into a buffer like this.
char *buf = new char[size+3];
buf[0] = comm;
buf[1] = (char)size;
buf[2] = (char)size+1;
strcpy(buf+3, data);
send(s, buf, size+3, 0);
but this doesnt seem to work with the size, as at the other end it always comes out as a different value.
anyone know how to do this?