C
cppquester
I am forced to work with a
char* buf;
I allocate memory and then construct some
data types in buf (several different at different locations of buf
kind of struct alike)
Sometimes all data need to be zeroed.
For integral types that is fine, I just zero all
char within buf.
Q: What about float, double, complex,
can I assume that a bit pattern of only 0s
corresponds to zero values also for these types?
What about std::string?
Is all zero bit pattern an empty string?
If not in the standard, than at least "de-facto"?
Or for g++ on i386?
My program does not need to work on "exotic" systems and
just zeroing the char array saves lot of resources.
Thanks,
Marc
char* buf;
I allocate memory and then construct some
data types in buf (several different at different locations of buf
kind of struct alike)
Sometimes all data need to be zeroed.
For integral types that is fine, I just zero all
char within buf.
Q: What about float, double, complex,
can I assume that a bit pattern of only 0s
corresponds to zero values also for these types?
What about std::string?
Is all zero bit pattern an empty string?
If not in the standard, than at least "de-facto"?
Or for g++ on i386?
My program does not need to work on "exotic" systems and
just zeroing the char array saves lot of resources.
Thanks,
Marc