Skip to content

Conversation

@xiafrog
Copy link

@xiafrog xiafrog commented Oct 25, 2016

No description provided.

int i, c;
while((c = getchar()) != EOF) {
for (i=1; s[i] && s[i]!=c; i++); // 找错位之后的字符在常量表中的位置
for (i=1; s[i]!=0 && s[i]!=c; i++); // 找错位之后的字符在常量表中的位置

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在C的逻辑判断,非0值为真,所以这边if(s[i])等价if(s[i] != 0),同理if(!x)等价if(x==0)
不过用if(s[i] != 0)更直观

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants