SHARE
TWEET

ASKpragmapack

a guest Nov 12th, 2019 78 in 341 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #pragma pack(1)
  6.  
  7. int main() {
  8.     typedef struct {
  9.         unsigned char a;
  10.         int b;
  11.         long c;
  12.     }MTestStruct;
  13.  
  14.     MTestStruct testStruct;
  15.     testStruct.a = 1;
  16.     testStruct.b = 2;
  17.     testStruct.c = 3;
  18.  
  19.     int size = sizeof(MTestStruct);
  20.     char* ptr = (char*)&testStruct;
  21.  
  22.     for (int i = 0; i < size; i++) {
  23.         printf("%02X", (unsigned char)ptr[i]);
  24.     }
  25.     printf("\r\n");
  26.  
  27.     printf("%i ", testStruct.a);
  28.     printf("%i ", testStruct.b);
  29.     printf("%i ", testStruct.c);
  30.  
  31.  
  32.     getchar();
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top