#include <cstdio>
#include <cstdint>
#include <cassert>
int main() {
std::uint64_t ui;
char c;
auto ret = std::sscanf("111K", "%lu64%[B, K, M, G]", &ui, &c);
assert(ret == 2);
assert(ui == 111);
}
我尝试使用从一个字符串sscanf
中读取 auint64_t
和 a ,但每次尝试此操作时char
它只读取它ui
(断言失败)。ret == 2