If you use cin to get that string, it's cin who separates them. You should use cin.getline instead of cin << (char *).
About alignment:
I think you still need to align the data's...
I had a lot of troubles with data alignment, so I always try to align whatever I send.
I've read somewhere on cplusplus.com about alignment, and I hope those infos were true.
What you should know is: Always try to use chars instead of bools, in everything, even in every class you are going to put in another struct.
And never pass pointers in a struct. They will not get "converted" to an actual string, but Send will send it's Hex address instead.
About the order, if they have the same size, there is no problem with ordering them. There is a order i guess, i simply do not know what it is.
I don't know the reason, i just always got told to do that, lol.
Anyways, when you need to send some characters with a struct, you may want to do something like this:
1 2 3 4 5 6 7 8 9
|
struct NOT_VALID {
char * Pointer; // This will be sent as a Memory Address, not as a Value!
};
struct VALID {
char Text[512]; // You can send up to 512 characters like this
// It will ALWAYS send 512 characters, indifferently if you write more or less
// To copy a string, remember you can use strcpy or memcpy.
// You may find useful to use strncpy because of its length-limits
};
|
I'm sorry but i cannot answer all of your question about alignment... I don't know those answers for myself either... Lol.
Oh, and if you use RakNet, there are a couple of functions that allows byte-alignment at runtime (Like, you make a unaligned struct, put it in a "BitStream" (A stream of data, you can put whatever you want in whatever size) in a "aligned" way (RakNet::BitStream::WriteAlignedX , where X is the Bit-alignment factor, and RakNet will fill the unaligned missing space with 0's i guess). There is even a string compression class. (For string, i mean char *'s).
And if you use Microsoft's Visual Studio, you can align structs like this:
1 2 3
|
#pragma pack(push, 1)
/* Define here your structs */
#pragma pack(pop)
|
Have fun, and I hope all I wrote above is right and can help you!