- #include <iostream>
-
-
#include <sstream>
-
-
#include <fstream>
-
-
#include <string>
-
-
#include <bitset>
-
-
#include <stdlib.h>
-
-
using namespace std;
-
-
-
-
int main()
-
-
{
-
char array[4] = {0x01, 0x02, 0x03, 0x04};
-
-
cout << hex << (int)array << "\t" << (int)(array + 1) << "\t"
-
-
<< (int)(array + 2) << "\t" << (int)(array + 3) << endl;
-
-
cout << hex << (int)*array << "\t" << (int)*(array + 1) << "\t"
-
-
<< (int)*(array + 2) << "\t" << (int)*(array + 3) << endl;
-
-
int *b = (int *)array;
-
-
cout << hex << (int)*b << endl;
-
-
if(*b == 0x01020304)
-
-
cout << "Little endian!" << endl;
-
-
else if(*b == 0x04030201)
-
-
cout << "Big endian!" << endl;
-
-
else
-
-
cout << "Error!" << endl;
-
-
-
-
system("pause");
-
-
return 0;
-
-
}
Output:
22ff08 22ff09 22ff0a 22ff0b
1 2 3 4
4030201
Big endian!
请按任意键继续. . .
阅读(495) | 评论(0) | 转发(0) |