【发布时间】:2022-06-27 23:27:52
【问题描述】:
我有字符串“word123”需要使用 sscanf 只提取“word”。
char str[10];
sscanf("word1233","%s", str);
【问题讨论】:
-
您最好使用适当的解析器逐个字符地进行...但是...
sscanf("word123", "%[^0123456789]", str);应该这样做...ideone.com/76L81O