gpt4 book ai didi

c - 在 C 中使用 char 时遇到问题

转载 作者:太空宇宙 更新时间:2023-11-04 01:31:45 26 4
gpt4 key购买 nike

我是 C 语言的新手,在使用字符时遇到了问题。我有一个大字符串分配给

char *test = "very large string of characters";

当我尝试写出字符串时 printf("%s", 测试);

它向我展示了完整的字符串,但是如果我尝试这样做

printf("%s", test); 
printf("%s", test);

第二个 printf 只显示大约 20% 的字符串。

如何让测试在不被截断的情况下写出两次?

最佳答案

执行 fflush(stdout) 否则它可能会被缓冲。

关于c - 在 C 中使用 char 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21318570/

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