KVstorageBaseRaft-cpp
KVstorageBaseRaft-cpp copied to clipboard
util.h文件中format 格式化函数
类似于 printf 的功能,
首先,使用 'std::snprintf' 计算格式化后的字符串长度,加上 1 以包括终止符。
然后,根据计算的大小分配一个字符缓冲区,使用 'std::snprintf' 将格式化后的字符串写入缓冲区。
最后,将缓冲区内容转换为 std::string,并去掉终止符 \0,返回结果
测试截图: