Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个表单的输入字符串
char *s = "one.two three"
我想把它分成 3 个字符串变量。我正在做
sscanf(s, "%s.%s %s", one, two, three);
但它在“one.two”中读取为变量一的字符串。我如何处理“。” 和sscanf的空格?
说明%s符只停止一个空格。尝试类似:
%s
sscanf(s, "%[^.].%s %s", one, two, three);
有趣的是,它可能不可能产生一个可接受的输入,"%s.%s %s"因为%s只停止一个空间,但.必须立即跟随它。
"%s.%s %s"
.