CodePudding user response:
Make sure the size, then there is a pointer, operation,CodePudding user response:
Fyi:# include & lt; stdio.h>
#include
#include
Unsigned int iv, I;
Unsigned char BCD [5].//fixed-length 10
BCDUnsigned char sv [11].
Void main () {
Iv=123456789;//the biggest 10 are unsigned integers
//INT2BCD
Sprintf (sv, "% 010 u", iv);
for (i=0; i<10; I +=2) {
BCD [I/2]=(sv [I] <4) | (sv [I + 1] & amp; 0 x0f);
}
Printf (" BCD=% 02 x % 02 02 x % 02 x % 02 x x % \ n ", BCD [0], BCD [1], BCD [2], BCD [3], BCD [4]);
//BCD2INT
for (i=0; i<10; I +=2) {
Sv [I]='0' | (BCD [I/2] & gt;> 4);
Sv=[I + 1] '0' | (BCD [I/2] & amp; 0 x0f);
}
Sscanf (sv % 010 "u", & amp; Iv);
Printf (" iv=% 010 u \ n ", iv);
getch();
}