Help - Building a packet for W/L transmission

Using cheap RF wireless modules and the VirtualWire library I`m trying to send data from one arduino to another so that I can read in the data to a processing sketch. I figured the best way was to decide on a specific format and just make up a packet before sending it.

I had decided on a packet starting with 1 command byte, followed by any number of data bytes, until it comes to a terminating character.

The examples in the virtualwire documentation sends strings like this..

const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg));

My problem is actually building up the string to send. Lets say I want to send a sonar range result. The first byte would be S, then the distance integer follows, then add the terminator. This is my attempt..

void rfPacketOut(char commandChar, int data)
  char* packet;
  char* buffer;
  packet[0] = commandChar;
  itoa(data, buffer, 10);
  strcat(packet, buffer);
  strcat(packet, "\n");
  vw_send((uint8_t *)packet, strlen(packet));

But if I try something like rfPacketOut('A', 134); the serial and w/l output are both blank. I don`t think I know enough about strings/characters/pointers etc to really know whats going on :-/

char* packet;
  char* buffer;
  packet[0] = commandChar

"packet" doesn't point to anything - you haven't initialised it, simply declared it, "packet [0]" (or "*packet") could be anywhere - this is one of the main dangers of C programming.

Same goes for "buffer".

typedef struct {
  byte command;
  char buffer [11];   //don't forget to account for the terminator.
} packet_t;
packet_t packet;

  packet.command = commandChar;
  itoa(data, packet.buffer, 10);

  vw_send((uint8_t *)&packet, sizeof(packet));

Might be one solution to start playing with.