I am trying to clear all the individual bits in an unsigned char and i assigned the char to zero.I am not sure if thats the right way
This is a discussion on Clearing all bits in an unsigned char within the C++ Programming forums, part of the General Programming Boards category; I am trying to clear all the individual bits in an unsigned char and i assigned the char to zero.I ...
I am trying to clear all the individual bits in an unsigned char and i assigned the char to zero.I am not sure if thats the right way
That is one way (though you probably meant "I assigned zero to the char").
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
calloc is originally from C but you can use it in C++ too.
It puts zeros in the allocated memory chunk
calloc - C++ Reference
Mac OS 10.6 Snow Leopard : Darwin
calloc is a wrong solution here both in C and C++ since its primary purpose is dynamic memory allocation. You were probably thinking of memset instead.Originally Posted by nacho4d
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
In C++, there is std::fill instead of memset.