Pointer problems

hi,

i am writing a small network game just to learn how things work. now i have a problem, i will try to explain what it is.

i have a struct called packet that contains 2 vars 1 with the type of packet and the other with the data.

i then send it to my client.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
typedef enum commands 
{ 
	cmdConnect = 1,
};

struct Packet
{
	commands commmand;
	BALL Data; // i actualy want to make this a generic data type
};

void send_packet(BALL data)
{
	commands i = cmdConnect;

	Packet pack = Packet();
	pack.commmand = i;
	pack.Data = data;

	
    sendto(Socket, (char*)&pack, sizeof(pack), 0, (sockaddr*)&RemoteAddress,
           sizeof(sockaddr));
}


the way it is now i get the data just perfectley to the other side. but what if i want to send lets say my Bat data witch contains the location and speed of that. how would i change Packet to allow for a dynamic data source.

i have tried
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct Packet
{
	commands commmand;
	char* Data;
};

void send_packet(BALL data)
{
	commands i = cmdConnect;

	Packet pack = Packet();
	pack.commmand = i;
	pack.Data = (char*)&data;

	
    sendto(Socket, (char*)&pack, sizeof(pack), 0, (sockaddr*)&RemoteAddress,
           sizeof(sockaddr));
}


bu then i would just receive the pointer of the pointer and not the data behind it.

i'm pretty new to c++ so i was wondering if any of you could help me.
Topic archived. No new replies allowed.