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.
我想将字符串“abc 123 456”拆分为字符串(“abc”)和 2 个数字(123,456)。我应该在下面的代码中输入什么格式?
char *s; int a,b; sscanf("acb 123 456", format, s, &a, &b);
你要:
"%s%d%d"
但是您还需要为提取的字符串分配缓冲区空间:
char s[100]; int a,b; sscanf("acb 123 456", "%s%d%d", s, &a, &b);