问题描述:
C语言 K&R书上一道题
int getop(char s[])
{
int c,i;
while ((s[0] = c = getch()) == ' ' || c == '\t') ;
s[1] = '\0';
i = 0;
if (islower(c)){
while (islower(s[++i] = c = getch()))
;
s[i] = '\0';
if (c = EOF)
ungetch(c); /* went one char too far */
if (strlen(s) > 1)
return NAME; /* >1 char;it is a NAME */
else
return c; /* it may be a command */
}
if isdigit(c) && c = '.' && c = '-')
return c; /* not a number */
if (c == '-')
if (isdigit(c = getch()) || c == '.')
s[++i] = c; /* negative number */
else{
if (c = EOF)
ungetch(c);
return '-';
}
if (isdigit(c))
while (isdigit(s[++i] = c = getch()))
;
if (c = '.')
while (isdigit(s[++i] = c = getch()))
;
s[i] = '\0';
if (c = EOF)
ungetch(c);
return NUMBER;
}
中为什么要:return c; /* it may be a command */ 此时c不是哪个被压进缓冲区的字符么
int getop(char s[])
{
int c,i;
while ((s[0] = c = getch()) == ' ' || c == '\t') ;
s[1] = '\0';
i = 0;
if (islower(c)){
while (islower(s[++i] = c = getch()))
;
s[i] = '\0';
if (c = EOF)
ungetch(c); /* went one char too far */
if (strlen(s) > 1)
return NAME; /* >1 char;it is a NAME */
else
return c; /* it may be a command */
}
if isdigit(c) && c = '.' && c = '-')
return c; /* not a number */
if (c == '-')
if (isdigit(c = getch()) || c == '.')
s[++i] = c; /* negative number */
else{
if (c = EOF)
ungetch(c);
return '-';
}
if (isdigit(c))
while (isdigit(s[++i] = c = getch()))
;
if (c = '.')
while (isdigit(s[++i] = c = getch()))
;
s[i] = '\0';
if (c = EOF)
ungetch(c);
return NUMBER;
}
中为什么要:return c; /* it may be a command */ 此时c不是哪个被压进缓冲区的字符么
问题解答:
我来补答展开全文阅读