[Solved] C++ Convert part of the Array into int

[ad_1] Hard to be sure because your question isn’t very clear. But perhaps this is what you want uint16_t z = *reinterpret_cast<uint16_t*>(array); Another possiblity is uint16_t z = static_cast<uint8_t>(buf[0])*256 + static_cast<uint8_t>(buf[1]); and another is uint16_t z = static_cast<uint8_t>(buf[1])*256 + static_cast<uint8_t>(buf[0]); Try them all, they differ only in what endianness they use. You should look that … Read more

[Solved] Multiple ternary operators and evaluating int as boolean mystery [closed]

[ad_1] Why does any combination of true and false return the value it does? There is no combination of any boolean here. This ?: operator returns first or second expression, not the condition itself. condition ? first_expression : second_expression; The condition must evaluate to true or false. If condition is true, first_expression is evaluated and … Read more