经常自己写一些控制台(Console)的应用程序,在其中输出超级长的信息时,发现只能看到后面的信息,前面的则看不到。例如以下程序片段:int i;for( i = 0; i < 10000; i++ ) { printf( "this is the %d line\n", i ); }请问有什么方法,可以查看到以上输出的每一行?
for( i = 0; i < 10000; i++ ) { printf( "this is the %d line\n", i ); if(i%100==0) system("pause"); } 这样就每100行停顿下,等待你敲入按键
system("pause");这个函数是用到哪个头文件的,我编译不了。这是我的代码:#include <stdio.h>void main() { int i; for( i = 0; i < 10000; i++ ) { printf( "this is the %d line\n", i ); if(i%100==0) system("pause"); } }
for( i = 0; i < 10000; i++ )
{
printf( "this is the %d line\n", i );
if(i%100==0)
system("pause");
} 这样就每100行停顿下,等待你敲入按键
system("pause");这个函数是用到哪个头文件的,我编译不了。这是我的代码:#include <stdio.h>void main()
{
int i; for( i = 0; i < 10000; i++ )
{
printf( "this is the %d line\n", i );
if(i%100==0)
system("pause");
}
}
#include <stdlib.h>
那么在cmd中执行 console.exe >> console.txt然后查看console.txt就好了
添加了#include <stdlib.h>头文件之后就OK了,谢谢大家的帮助。