如何解决C标准在哪里定义else if语句?
我只是对C中的50
语句感到好奇,所以我查看了C99标准,却一无所获。然后我看了一下语法,但又没有看else if
else if
在C中如何声明selection_statement
: IF '(' expression ')' statement
| IF '(' expression ')' statement ELSE statement
| SWITCH '(' expression ')' statement
;
。通过阅读该标准,我怎么能注意到它是其中的一部分?
解决方法
C 2018 6.8.4说,选择声明可能是“ let query = CKQuery(recordType: "Image",predicate: NSPredicate(format: "post = %@",CKRecord.Reference(recordID: CKRecord.ID(recordName: yourPostRecordName),action: .deleteSelf)))
let operation = CKQueryOperation(query: query)
var images = [CKRecord]()
operation.recordFetchedBlock = { record in
//Load up all the images
images.append(record)
}
operation.queryCompletionBlock = { cursor,error in
//All the image records have been downloaded,or there was an error
}
yourContainerDatabase.add(operation)
表达式 if (
声明 { {1}} 声明”。 C 2018 6.8表示后一个 statement 可能是“ selection-statement ”,因此它可能是)
或else
语句,结果在包含if
的语句中。
通过声明以下语法,在{6.8.4 / 1,C18中,else if
语句正式定义为if
语句的副产品:
语法
1个选择语句:
if ( expression ) statement
if ( expression ) statement else statement
资料来源:C18,第6.8.4 / 1/1
后一种形式的最后一个“ 声明”描述了if
之后可以跟随另一个else
语句。
除此之外,您可以在G.5.1 / 8的代码示例中的规范附录G中找到一个在C标准中使用的示例,当然是非规范的:
if (isnan(x) && isnan(y)) { ... }
else if ((isinf(a) ||isinf(b)) && isfinite(c) && isfinite(d)) { ... }
else if ((logbw == INFINITY) && isfinite(a) && isfinite(b)) { ... }
这是唯一出现else if
语句的地方,就像在C18标准中一样。
所以关于:
通过阅读标准,我怎么能注意到它是其中的一部分?
尽管示例是非规范的,但至少是示例的一部分。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。