QT uses printf() to print the results

printf() print

尝试在QT中使用printf打印结果,但是每次都是要关闭程序后,才能在控制台显示,虽然结果都显示了出来,但是不是我们要的时机出现。
原来是因为打印结果在缓冲区未被释放,所以无法显示

solve

三步即可

1.引入文件	#include <stdio.h>
		stdio 就是指 “standard input & output"(标准输入输出)
	所以,源代码中如用到标准输入输出函数时,就要包含这个头文件!
	例如c语言中的 printf("%d",i); scanf("%d",&i);等函数。

2.使用printf() 
	eg:	printf("hello QT");

3.清空缓冲区
	fflush(stdout);
	fflush(stdout)刷新标准输出缓冲区,把输出缓冲区里的东西打印到标准输出设备上

The above can be solved using printf() to print the desired result in QT.
Of course, it is generally more convenient to use qDebug() to print.

Guess you like

Origin blog.csdn.net/qq_45646951/article/details/108778454