sscanf(line,"%d %64[^\n",&seconds,message);
d [^表示 – 最多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说明符.
原文地址:https://www.jb51.cc/c/111113.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。