经常自己写一些控制台(Console)的应用程序,在其中输出超级长的信息时,发现只能看到后面的信息,前面的则看不到。例如以下程序片段:int i;for( i = 0; i < 10000; i++ ) 
{
   printf( "this is the %d line\n", i );
}请问有什么方法,可以查看到以上输出的每一行?

解决方案 »

  1.   

    信息太多的话,最好是输出成文件,用fprintf. 要么就运行的时候加重定向符存成文件,比如abc.exe > c:\log.txt,这样可以把屏幕的输出信息存到文件中
      

  2.   


    for( i = 0; i < 10000; i++ ) 

      printf( "this is the %d line\n", i ); 
      if(i%100==0)
         system("pause");
    } 这样就每100行停顿下,等待你敲入按键
      

  3.   


    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");
    }
      

  4.   

    #include <stdio.h>
    #include <stdlib.h>
      

  5.   

    另外,也可以使用重定向输出到文件:假设编译后的程序为 console.exe,
    那么在cmd中执行 console.exe >> console.txt然后查看console.txt就好了
      

  6.   


    添加了#include <stdlib.h>头文件之后就OK了,谢谢大家的帮助。