c++ - Is there a better option than reinterpret_cast<char*> when reading from std::istream? -


i have following piece of code:

std::istream is; // ... stream initialization ...  while(is) {   uint32_t next4bytes = 0;   is.read(reinterpret_cast<char*>(&next4bytes), 4);   if(next4bytes == 218893066)   {     is.seekg(-4, std::ios_base::cur);     break;   }   else     is.seekg(-3, std::ios_base::cur); } 

is there other better way reinterpret_cast<char*> read 4 bytes std::istream uint32_t? (obviously other c-style cast)

i don't think there is, , don't think need one. you're taking 4 bytes , re-interpreting them; reinterpret_cast precisely describes intent.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -