fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. typedef struct{
  7. int d;
  8. int e;
  9. int f;
  10. }DEF;
  11.  
  12. typedef struct {
  13. int a;
  14. int b;
  15. DEF c[];
  16. }ABC;
  17.  
  18. struct PdschAppHeader
  19. {
  20. uint64_t dir : 1;
  21. uint64_t payloadVer : 3;
  22. uint64_t channelType : 4;
  23. uint64_t frameId : 8;
  24. uint64_t subframeId : 4;
  25. uint64_t slotId : 6;
  26. uint64_t symbolId : 6;
  27. uint64_t rnti : 16;
  28. uint64_t symbolSize : 16;
  29. };
  30.  
  31. void print_hex(const void* data, size_t size) {
  32. const unsigned char* p = reinterpret_cast<const unsigned char*>(data);
  33. for (size_t i = 0; i < size; ++i) {
  34. printf("%02x",p[i]);
  35. // std::cout << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(p[i]);
  36. }
  37. std::cout << std::endl;
  38. }
  39.  
  40. int main() {
  41. ABC abc;
  42. // your code goes here
  43. // cout << sizeof(abc) << endl << &abc.b<<endl<<abc.c <<endl;
  44. PdschAppHeader pds;
  45. memset(&pds, 0, sizeof(pds));
  46. pds.slotId = 36;
  47.  
  48. print_hex(&pds, sizeof(pds));
  49. cout << pds.slotId << endl;
  50.  
  51. return 0;
  52. }
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
0000400200000000
36