How can I convert vector of floats into a char*?
I have a collection of floats stored inside std::vector<float> id_list
:
0,
0,
0,
0,
0,
1.77636e-15,
2.35099e-38,
-7.10543e-15,
3.06107e-38,
....
and using this code to convert it:
char *ptr = (char*)&id_list[0];
std::string dump_string(ptr, id_list.size() * sizeof(float));
but dump_string.c_str()
returns empty, despite having some values stored in my vector. I'm expecting to get all values concatenated into a one, long string, ie.:
0,0,0,0,0,1.77636e-15,2.35099e-38,-7.10543e-15,3.06107e-38........