Integer Byte Swapping in C++
问题 I'm working on a homework assignment for my C++ class. The question I am working on reads as follows: Write a function that takes an unsigned short int (2 bytes) and swaps the bytes. For example, if the x = 258 ( 00000001 00000010 ) after the swap, x will be 513 ( 00000010 00000001 ). Here is my code so far: #include <iostream> using namespace std; unsigned short int ByteSwap(unsigned short int *x); int main() { unsigned short int x = 258; ByteSwap(&x); cout << endl << x << endl; system(