Answer the question
In order to leave comments, you need to log in
What will be the result?
In the textbook I came across this part of the code:
char vlstr[SZ];
........
int k=vlstr[j]-'0';
Answer the question
In order to leave comments, you need to log in
This is an ASCII
calculation .
Each character in the set has its own position number (numbering from zero).
In ASCII, the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 are in order, so their numerical codes are in order - 48, 49, 50, 51, 52, 53, 54, 55 , 56, 57.
Whatever digital symbol we take, its value in numerical form can be found by subtracting the zero position from its position.
Most compilers are based on the ASCII table, but this is not fixed anywhere. If the compiler is based on another table, then this code may not work if the numbers in it are not next to each other or are not in order at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question