gpt4 book ai didi

c - 将 printf 与非空终止字符串一起使用

转载 作者:太空狗 更新时间:2023-10-29 16:14:55 25 4
gpt4 key购买 nike

假设您有一个不是 null 终止的字符串并且您知道它的确切大小,那么如何在 C 中使用 printf 打印该字符串?我记得这样的方法,但我现在找不到......

最佳答案

printf 有可能,它是这样的:

printf("%.*s", stringLength, pointerToString);

无需复制任何内容,无需修改原始字符串或缓冲区。

关于c - 将 printf 与非空终止字符串一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3767284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com