void read_class_information(head* beginning, int scale_type) {
puts("hello");
// printf("hello");
}
我有一个由 main 调用的简单函数,并且 stdout 的 printf() 和 fprintf() 在其中不起作用。另一方面,puts() 工作得很好。我在 printf() 调用时没有打开任何文件,也没有任何错误。对可能出现的问题有什么建议吗?谢谢。
最佳答案
因为printf()
不会自动刷新输出流。另一方面,puts()
在传递的字符串末尾添加一个新行'\n'
。所以它可以工作,因为 '\n'
刷新了 stdout
。
尝试
printf("hello\n");
或者,显式刷新stdout
fflush(stdout);
就在 printf()
语句之后。
关于C - printf() 不工作,但 put() 工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44209950/