1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdint>
#include <iostream>
struct NetworkPacket {
uint_least8_t type;
uint_least16_t length;
uint_least32_t sequence_number;
};
void print_packet(const NetworkPacket& packet) {
std::cout << "Packet Type: " << static_cast<int>(packet.type) << std::endl;
std::cout << "Packet Length: " << packet.length << std::endl;
std::cout << "Sequence Number: " << packet.sequence_number << std::endl;
}
int main() {
NetworkPacket packet = {5, 1024, 123456789};
print_packet(packet);
return 0;
}
Back to cstdint