I'm reading this wonderful book called The C Programming Language 2nd Edition and I'm having a hard time understanding how to use this function that is on page 97. Here it is:
Can someone show me an example of this function in action and also explain what is up withCode:int getint(int *pn) { int c, sign; while (isspace(c = getch())) ; if (!isdigit(c) && c != EOF && c != '+' && c != '-') { ungetch(c); return 0; } sign = (c == '-') ? -1 : 1; if (c == '+' || c == '-') c = getch(); for (*pn = 0; isdigit(c); c = getch()) *pn = 10 * *pn + (c - '0'); *pn *= sign; if (c != EOF) ungetch(c); return c; }
? I just don't get these two lines. Thanks a lot.Code:for (*pn = 0; isdigit(c); c = getch()) *pn = 10 * *pn + (c - '0');