if '\"'==' "'

来源:互联网 发布:python requests的功能 编辑:程序博客网 时间:2024/06/05 19:29
C PRIMER PLUS 第5版165页例题chcount.c
#include<stdio.h>
#define PERIOD '.'
int main(void)
{
    int ch;
    int charcount=0;
while((ch=getchar())!=PERIOD)
    {
        if(ch!='"'&&ch!='\'')
          charcount++;
    }
    printf("There are %d non-quote characters.\n",charcount);
    return 0;
}
注意到
if(ch!='"'&&ch!='\'')
改为if(ch!='\"'&&ch!='\'')
或if(ch!='\"'&&ch!=''')
输出结果相同

原创粉丝点击