hmmm, right something very odd is going on... i'll post the important part of my code:
Code:
typedef struct enemyType
{
char header;
char playerNo;
float eyex, eyey, eyez;
} enemyType;
enemyType enemy[MAX_PLAYERS];
char noPlayers;
void writeStuff(char *writeBuffer) {
char playerCount;
int currentByte;
writeBuffer[0] = (char) 2;
currentByte = 1;
for (playerCount = 0; playerCount < noPlayers; playerCount++) {
writeBuffer[currentByte++] = playerCount;
writeBuffer[currentByte] = enemy[playerCount].eyex;
currentByte += 4;
writeBuffer[currentByte] = enemy[playerCount].eyey;
currentByte += 4;
writeBuffer[currentByte] = enemy[playerCount].eyez;
currentByte += 4;
}
}
now it seems in the function which i call this function, i can read the values of writeBuffer[2 / 6 / 10] using the %f notation in printf, and I will get a print value of 0.0000000; however trying this using the %d notation will get the correct truncated, increased by a power of ten!?!? i am really not sure what's going on. Here's I'll put in a initialisation function for you to try
Code:
void testInit(void) {
noPlayers = 2;
enemy[0].eyex = 1.0;
enemy[0].eyey = 1.0;
enemy[0].eyez = 65.34;
enemy[0].header = 2;
enemy[0].playerNo = 0;
enemy[1].eyex = 2.0;
enemy[1].eyey = 2.0;
enemy[1].eyez = 2.0;
enemy[0].header = 2;
enemy[0].playerNo = 1;
printf("Test data plugged in\n");
}