I've been toying around with storing data that will be operated on often into a large array of unsigned char(since C++ does not have a byte type). So, if I store a float into the char array, it will take up the 4 unsigned chars. Simple, except now if I want to edit that data while it is in the array, I would need to access all 4 elements at the same time, which is impossible as far as I know. So, is there a way to edit the 4 unsigned chars into the float value that I desire without resorting to a memcpy()?
Example:
#include <iostream>
#include <string.h>
#include <stdint.h>
using namespace std;
struct testEntity {
    float density;
    uint16_t xLoc, yLoc;
    uint16_t xVel, yVel;
    uint16_t xForce, yForce;
    uint16_t mass;
    uint8_t UId;
    uint8_t damage; 
    uint8_t damageMultiplier;
    uint8_t health;
    uint8_t damageTaken;
};
int main()
{
    testEntity goblin { 1.0, 4, 5, 5, 0, 0, 0, 10, 1, 2, 1, 10, 0 };
    testEntity goblin2;
    unsigned char datastream[24];
    unsigned char* dataPointer = datastream;
    memcpy(&datastream, &goblin, sizeof(testEntity));
    //I know that datastream[0..3] contains information on goblin.density
    //How would I edit goblin.density without memcpy into another testEntity structure?
    memcpy(&goblin2, &datastream, sizeof(testEntity));
return 0;
}
 
     
     
     
    