gpt4 book ai didi

c - fgets 无法在 1 行上显示多个 "%"

转载 作者:行者123 更新时间:2023-11-30 20:29:18 25 4
gpt4 key购买 nike

我想在 1 行上显示 fgets() 输入,这里是代码:

printf("%s study at %s and he is %i years old", siswa01.name, siswa01.school, siswa01.age);

当我运行程序时,输出如下:

jordan                                                                                                                   study at Las Vegas                                                                                                      and he is 12 years old

我想显示输出:

jordan study at las vegas and he is 12 years old

如何使用 fgets() 在 1 行上显示?

最佳答案

看起来您的 siswa01.name 变量不包含 jordan\0,而是 jordan ...\0,有数百个n 和字符串末尾之间有空格。
结果,你得到的打印结果是带有所有这些空白的。

问题出在填充该变量的代码中 - 您没有显示该变量,因此我们无法告诉您它出了什么问题。

关于c - fgets 无法在 1 行上显示多个 "%",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58469721/

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