Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?

why doesn’t reinterpret_cast handle that for me? One reason is that the size, alignment, and bit representations aren’t specified, so such a conversion wouldn’t be portable. However, that wouldn’t really justify making the behaviour undefined, just implementation-defined. By making it undefined, the compiler is allowed to assume that expressions of unrelated types don’t access the … Read more

PHP read file as an array of bytes

I believe the code you are looking for is: $byteArray = unpack(“N*”,file_get_contents($filename)); UPDATE: Working code supplied by OP $filename = “myFile.sav”; $handle = fopen($filename, “rb”); $fsize = filesize($filename); $contents = fread($handle, $fsize); $byteArray = unpack(“N*”,$contents); print_r($byteArray); for($n = 0; $n < 16; $n++) { echo $byteArray [$n].'<br/>’; }

What’s the prefix for binary in PHP?

As of PHP 5.4+ the prefix for binary number is: 0b For ealier version, there is no such prefix. Instead, you can use 0x, for hexadecimal. For more informations, see the Integers section of the PHP manual. Still, if you really need to write values using binary before PHP 5.4, you can use the bindec … Read more