casting

Is this a valid method to cast from hex to size_t?

wordVector_[i] = (size_t)0xFF;
Yes, but in C++ use static_cast instead

 
size_t val = static_cast<size_t>( 0xFF );


Although better yet is to avoid the cast altogether:

size_t val = 0xFFU;

(U means unsigned which is what size_t is).
Topic archived. No new replies allowed.