# Thread: Dont Understand some code

1. ## Dont Understand some code

Hey ppls am going to study computer science in Jan but am trying to learn the
fundamentals for C,
Code:
```int main(){
int c, white, other, i;
int digit;
white = other = 0;
for(i = 0; i <10; i++){
digit[i] = 0;
}
while((c = getchar())!=EOF){
if(c >= '0' && c <= '9'){
++digit[c-'0'];
}
else if(c == ' '|| c == '\t'|| c == '\n'){
++white;
}
else{
++other;
}
}
for(i = 0; i < 10; i++){
printf("%d  ",digit[i]);
}
printf(" \n%d\n%d",white,other);
return(0);
}```
so this code i understand what it does and how it does it but the ++digit[c-'0']
i dont get. I know its adding one to digit array but what does c-'0' mean,
does c equal the char 0 or is it c minuz the char 0 or what am confused. 2. c is a char and can be thought of as a character, but that's just a convenience for us; it is actually stored as a number (generally in ASCII). 3. In C, character literals such as '0', 'z' and 'L' are usually just ways to help remember what ASCII Code we're referencing. (Don't confuse this with double quotes or strings!) In this case, c-'0' is equivalent to c-48. The ASCII numbers start at 48, so just taking that away will give the actual number, not the ASCII code. 4. ooooooo thank you i been trying to solve this without realize the ASCII code, so basiclly if the input is '1' it will be 49 - 48 = 1 so its giving the the char a numerical value
so that the digit array can read it. i get it thank you
am a noob at this haha ty Popular pages Recent additions arrays in c, dont understand, help me plz, understanding 