You don't need memcpy
for this... That would be useful if you were copying a float array into a buffer elsewhere in memory. All you really need is to use a different pointer type to look into the character array.
const size_t BUFSIZE = 4096;
char buffer[BUFSIZE];
float *f_buf = (float*)buffer;
If all you wanted was to stick a single float into the start of the buffer, either of the following two lines is okay:
*f_buf = 0.00895;
f_buf[0] = 0.00895;
All it's really doing is letting you see the buffer as an array of floats.
int i;
/* Put a bunch of floats into the buffer */
for( i = 0; i < 10; i++ ) {
f_buf[i] = i / 2;
}
/* Display contents of buffer in hex */
for( i = 0; i < 10 * sizeof(float); i++ ) {
printf( "%02x", (int)buffer[i] );
}
printf( "\n" );
/* Sanity-test the buffer contents */
for( i = 0; i < 10; i++ ) {
printf( "%d: %f\n", i, f_buf[i] );
}