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);
しかし、変数1の文字列として「one.two」を読み込んでいます。「。」をどのように処理しますか。sscanfの空白?
指定子は%sスペースでのみ停止します。次のようなものを試してください:
%s
sscanf(s, "%[^.].%s %s", one, two, three);
興味深いことに、はスペースで止まるだけで、その直後に が続く必要があるため"%s.%s %s"、の許容可能な入力を生成することはおそらく不可能です。%s.
"%s.%s %s"
.