China Naming Network - Company naming - Convert octal positive integer string to decimal program explanation
Convert octal positive integer string to decimal program explanation
n=0; //Initialize n=0
while(*p++!='\0') //Determine whether the octal string ends and point to the next one Numeric characters
n=n*8+*p-'0'; //If it does not end, calculate the decimal value of the number. *p Take the character code (ASCII code) of a certain number from the left. Since the ASCII code of the numbers 0-9 is 30-39, you need to subtract the ASCII code 30 of '0' to get 0-9.