I'm a novice in C and I came across the code like this :
int n[10];
if(c>='0' && c<='9')
++n[c-'0']
In if
loop why we have to use single quotes around 0
, whats the use of it, why we can't define 0
as an integer straight away? And in the second line of code ++n[c-'0']
, whats the use of using array like this, in sense why we need to subtract 0
(once again why the use of single quotes in this context?) from c
in the array index?
If i do like this n[c-'0']
, the result of index operation(c-'0'
) will be an character or integer?
Given that can anyone say me, whats the real use of such array and what are the disadvantages well?
Thanks in advance.
See Question&Answers more detail:os