I am learning chapter 2: types, operators and expressions of "The C programming language Edition 2", and encounter such a snippet of code:
/* atoi: convert s to integer */
int atoi(char s[]) {
int i, n;
n = 0;
for (i=0; s[i]>='0' && s[i] <= '9'; ++i)
n = 10 * n + (s[i] - '0');
}
What's puzzle me is that n = 10 * n + (s[i] - '0');
is not enbraced within {}
, I assume it should be
/* atoi: convert s to integer */
int atoi(char s[]) {
int i, n;
n = 0;
for (i=0; s[i]>='0' && s[i] <= '9'; ++i) {
n = 10 * n + (s[i] - '0');
}
}
What's the problem with my assumption?