small quiz about r & p

#include <iostream>
#include <stdint.h>
using namespace std;

int main() {
// your code goes here
short int buff[5]  = {1, 1, 1, 1, 0};
cout << *(int32_t*)(&buff[3]); // get the value of the remainder of buff from 3rd position as a int32 value 指 buff第3个位置起,看作一个4位整数
return 0;
}

cout << *(int32_t*)(&buff[3]);  output: 1 from 00000000 00000001 (3rd is 1 and 4th is 0)

cout << *(int32_t*)(&buff[2]); output: 65537 from 00000001 00000001 (2nd is 1 and 3rd is 1 too)

short int has 2 bytes, 16 bits

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s