Using %d with sscanf can cause a problem, because %d can be 2 bytes or 4 bytes. It is said in earlier days %d used to be 2 bytes, but in more modern environments %d became 4 bytes. To be certain it is 2 bytes, replace %d with %hu or %hd or %hi