Try using the "%h"
modifier:
scanf("%hu", &length);
^
ISO/IEC 9899:201x – 7.21.6.1-7
Specifies that a following d , i , o , u , x , X , or n conversion
specifier applies to an argument with type pointer to short or
unsigned short.
Try using the "%h"
modifier:
scanf("%hu", &length);
^
ISO/IEC 9899:201x – 7.21.6.1-7
Specifies that a following d , i , o , u , x , X , or n conversion
specifier applies to an argument with type pointer to short or
unsigned short.