Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.h文件中format 格式化函数 #79

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

beanljun
Copy link
Contributor

@beanljun beanljun commented Aug 5, 2024

类似于 printf 的功能,

首先,使用 'std::snprintf' 计算格式化后的字符串长度,加上 1 以包括终止符。

然后,根据计算的大小分配一个字符缓冲区,使用 'std::snprintf' 将格式化后的字符串写入缓冲区。

最后,将缓冲区内容转换为 std::string,并去掉终止符 \0,返回结果

测试截图:
5070734414

@578223592
Copy link
Collaborator

@beanljun sorry for the late reply. looks good for me. thanks a lot~~~

@578223592 578223592 merged commit a5541d7 into youngyangyang04:main Aug 29, 2024
1 check passed
@578223592 578223592 linked an issue Aug 29, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

util.h文件中的模板函数format
2 participants