Guest User

Untitled

a guest
May 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package main
  2.  
  3. /*
  4. typedef struct{
  5. unsigned char a;
  6. char b;
  7. int c;
  8. unsigned int d;
  9. char e[10];
  10. }unpacked;
  11.  
  12. #pragma pack(1)
  13. typedef struct{
  14. unsigned char a;
  15. char b;
  16. int c;
  17. unsigned int d;
  18. char e[10];
  19. }packed;
  20.  
  21. */
  22. import "C"
  23. import (
  24. "fmt"
  25.  
  26. "github.com/davecgh/go-spew/spew"
  27. )
  28.  
  29. func main() {
  30. unpack := C.unpacked{}
  31. pack := C.packed{}
  32.  
  33. fmt.Println("Printing the structure of the unpacked struct")
  34. fmt.Printf("%+v\n", unpack)
  35.  
  36. fmt.Println("Printing the structure of the packed struct")
  37. fmt.Printf("%+v\n", pack)
  38. }
Add Comment
Please, Sign In to add comment