Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
2 バイトの短い int がありますが、左側のバイトのみをファイルに出力したいと考えています。どうすればいいですか?二項関数open()、read()、write()などを使用しています。
また、右バイトを左に 8 回シフトして、右バイトが左を占有し、右バイトがすべて 0 にクリアされるようにします。
私がすでに試したことを示していないことをお詫びします-私はCの初心者であり、これを行う方法について何も見つかりません.
このアプローチを試すことができます
int someNum = 0x1234; int leftByte, rightByte; leftByte = (someNum >> 8) & 0xff; rightByte = (someNum) & 0xff;