gpt4 book ai didi

c - %[^<] (和 friend )在格式化字符串系列中是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 00:29:34 24 4
gpt4 key购买 nike

A comment (可能应该作为答案提交)有代码

sscanf(string, "<title>%[^<]</title>", extracted_string);

运行代码似乎复制了 <title> 之间的文本标记为 extracted_string , 但我在 man pages 中找不到任何对 printf 系列插入符号的引用或 elsewhere online .

谁能给我指出解释 %[^<] 用法的资源? ,和其他类似的语法,在 sscanf()家人?

最佳答案

来自 C11 标准文档,章节 §7.21.6.2,第 12 段,转换说明符,(强调我的)

[

Matches a nonempty sequence of characters from a set of expected characters (the scanset).

....

The conversion specifier includes all subsequent characters in the format string, up to and including the matching right bracket (]). The characters between the brackets (the scanlist) compose the scanset, unless the character after the left bracket is a circumflex (^), in which case the scanset contains all characters that do not appear in the scanlist between the circumflex and the right bracket.

A draft version of the standard, found online .

关于c - %[^<] (和 friend )在格式化字符串系列中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30304888/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com