Original Post
🔒 Locked
easy void * ?
Advertisement
The easiest way is just to make the void* point at the float...
If you really have to store the value of the float in the void*, it is very difficult (impossible?) to do with straight casting, easier to use memcpy()..
|
If you really have to store the value of the float in the void*, it is very difficult (impossible?) to do with straight casting, easier to use memcpy()..
|
Why would you want to convert a float to a void*? If you want to pass it to some function that accepts a void*, taking the address of the float variable should be enough. Messing with void* is to be avoided (pun intended 
Another tip: instead of strtofloat(char string[64]), declare it as strtofloat(const char* str). Specifying the string parameter as a char array of length 64 is not much use, since it will be converted to char* anyway (in standard C). A pointer to a character is sufficient. The const tells that the function doesn''t modify the string.
HTH,
Erik
Another tip: instead of strtofloat(char string[64]), declare it as strtofloat(const char* str). Specifying the string parameter as a char array of length 64 is not much use, since it will be converted to char* anyway (in standard C). A pointer to a character is sufficient. The const tells that the function doesn''t modify the string.
HTH,
Erik
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement