dealing with ints stored in char variables
I'm learning C and I am doing a code review. Now I am looking at a line I have no clue what it's doing... could you guys help me out? It says:
int number = (array - '0') - 1; // array is of the type char * and in the position 3 will have a 1,2,3 or 4.
The part I don't get is the "- '0'" part...
integer to character conversion by ASCII standard
It is Just default type conversion. Normally character values will convert into integer based on its ASCII value.
For Ex: '0' will be taken as 48 in ASCII value. So C follows this ASCII standard for conversion.