Char CharType [6]; //Defines an array of type char.
strcpy (CharType, "0.001"); //assigns the string "0.001" to the CharType array.
itoa (i_value_flag, CharType); //converts the int variable to a string, and assigns the value to the Chartype array.
when I converted the int variable to a string, I found the string displayed in reverse order. Like I_value_flag equals 123456, on the interface.
The display is 654321,(Of course strcpy (CharType, "123456") can be displayed 123456).
All I wrote again was the function of a reverse order.
j = 0;
i = 0;
while (j==0) {
if (Chartype[i]==0) {
j = 1;
}Else {
i++;
}
if (i>5) J=1;
}//Here first count the valid characters is how many, if the valid character is 4, the storage effect is ' 4 ' 3 ' 2 ' 1 ' + ', because ' the ' + ' does not reverse the order, so the statistics to the 4 valid number is stored in the I variable inside.
i--;
j=0;
while(j==0) {
if(Chartype[i]= = ' 0 ' && i>0) {
Chartype[i]= ' + ';
i--;
}ElseJ=1;
}//Clear out the extra 0, if it is next to the ' + ' character, ' 0 ' exists, change this ' 0 ' to ' + '. Because I mostly show numbers
K = I/2;//If I equals odd, for example I equals 5, just K equals 2. That is, the third person does not swap.
L = i;
for(i=0;i<k;i++) {
C_value_flag =Chartype[l-i];
Chartype[l-i]=Chartype[i];
Chartype[i]=C_value_flag;
}//adjust to the order of valid characters, such as 1 and 5 swap, 2 and 4 swap, 3 unchanged.
The C language assigns a string to an array of type char.