gpt4 book ai didi

c - %64[^ C 中的说明符

转载 作者:太空狗 更新时间:2023-10-29 17:20:47 24 4
gpt4 key购买 nike

sscanf(line, "%d %64[^\n", &seconds, message);

%64[^ 是指最多 64 个字符吗?它应该与 GNU C 编译器一起工作吗?

最佳答案

意思是“最多读取 64 个字符或到达换行符时停止,以先到者为准”。它由标准指定,因此所有标准库都必须支持它。

C11 7.21.6.2

[ 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.

如评论中所述,可能需要匹配的 ] 来分隔扫描列表。 s 说明符不是必需的

关于c - %64[^ C 中的说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10750175/

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