M
mdh
May I ask the learned board this. Is it correct to assume that a
character (in this case "c") is always converted to an integer, so
that line 2 below ( specifically c - '0' ) will always give the
value as an integer of it's digit representation? (Snippet from page
97 K&R). If the question does not make too much sense, it is because I
am missing something.
f(int *ptr){...
int c;
....
for ( *ptr = 0; isdigit(c); c = getch() ) /* getch gets the next
character from the input */
*ptr = *ptr * 10 + (c - '0'); <----Line 2
....}
character (in this case "c") is always converted to an integer, so
that line 2 below ( specifically c - '0' ) will always give the
value as an integer of it's digit representation? (Snippet from page
97 K&R). If the question does not make too much sense, it is because I
am missing something.
f(int *ptr){...
int c;
....
for ( *ptr = 0; isdigit(c); c = getch() ) /* getch gets the next
character from the input */
*ptr = *ptr * 10 + (c - '0'); <----Line 2
....}