Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Newbie...How to stop screen scrolling past really quickly...Help

michaeltmichaelt Member Posts: 4
When I run a programme to view a files content the DOS window opens as it should. Then a list of the file content race by until the system ("pause"); command is reached.

Is there a C++ command which enables me to view the files content screen by screen, something like the "/p" command in DOS

I'm using Dev-CCP ver 4.5.9.0

Many thanks

Michael

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    : When I run a programme to view a files content the DOS window opens as it should. Then a list of the file content race by until the system ("pause"); command is reached.
    :
    : Is there a C++ command which enables me to view the files content screen by screen, something like the "/p" command in DOS
    :
    : I'm using Dev-CCP ver 4.5.9.0
    :
    : Many thanks
    :
    : Michael
    :

    One way to handle that outside your program is to start your program from a cmd prompt then redirect its output to more.exe.

    c:>>myprogram | more

    If you want to do that within your program you would have to have a line counter and put a pause every so-many lines that are displayed. For example:

    #include
    int main()
    {
    int line_counter = 0;
    for(;;)
    {
    //display a line
    line_count++;
    if(line_count == 20)
    {
    cout.ignore();
    line_count = 0;
    }
    }
    }

  • michaeltmichaelt Member Posts: 4
  • bad_codebad_code Member Posts: 106
    : When I run a programme to view a files content the DOS window opens as it should. Then a list of the file content race by until the system ("pause"); command is reached.
    :
    : Is there a C++ command which enables me to view the files content screen by screen, something like the "/p" command in DOS
    :
    : I'm using Dev-CCP ver 4.5.9.0
    :
    : Many thanks
    :
    : Michael
    :
    Instead of using more, a more common practice is to redirect the output to a file and then view the file in the complier/editor.

    myfile.exe > myfile.out

    also you can redirect errors to the file like this

    myfile.exe > myfile.out 2>&1



  • Andre YoungAndre Young USAMember Posts: 0

    _ // http://forcoder.org // free video tutorials and ebooks about || Scratch PHP Visual Basic .NET R C Python Swift Ruby Java Visual Basic C# MATLAB Perl C++ Go Delphi PL/SQL Assembly JavaScript Objective-C Prolog Logo Hack F# ABAP D VBScript Rust Scheme Julia Clojure FoxPro Alice Scala Ada Erlang Fortran LabVIEW Awk Crystal COBOL Lua ML Kotlin Transact-SQL Dart SAS Apex Bash Lisp || _____________

Sign In or Register to comment.