#include #include #include using namespace std; int main() { ofstream out ("test.bin", ios::binary); short *a = new short[10]; char *b = (char*)a; for (int i=0; i<10; i++) { a[i] = -1938+i; } for (int i=0; i<20; i++) { printf("%X ", (unsigned char)b[i]); } printf("\n"); for (int i=0; i<20; i++) { printf("%X ", ((unsigned char*)a)[i]); } printf("\n"); out.write((char*)a, 10*sizeof(short)); out.write(b, 10*sizeof(short)); out.write(b, 20); out.close(); return 0; }