【发布时间】:2016-04-27 10:10:24
【问题描述】:
while (!EOLorEOFfound) {
int ch == fgetc(stdin);
EOLorEOFfound = ch == '\n' || ch == EOF;
}
注意:EOLorEOFfound 是 bool 类型。
StackOverFlow 用户就另一个问题给了我这个答案。见这里:
How to determine if fgets stopped before all letters were read?
现在,我一直在疑惑最后一行代码中的表达式实际上做了什么。我怀疑它可能是某种形式的三元运算符?
【问题讨论】:
-
int ch == fgetc(stdin);可能是一个错误,应该是int ch = fgetc(stdin);(=而不是==)
标签: c syntax variable-assignment logical-operators