How do I show an output from a file automatically?
Some outputs can be 1000's of lines long that can exceed the screen's limit only showing part of the output. I can output the results to a file but is there a solution for the program to open the output file automatically? I was suggested using 'system()' from 'stdlib.h' but I don't know how? any suggestions or help?

here's a sample code: (the commented lines are the implements)

#include<iostream.h>
#include<fstream.h>
// #include<stdlib.h>

void main()
{
ofstream OutFile ("C:/output.txt")
for ( int i = 0; i < 100; i++ ) { OutFile << i << endl; }
// system() //what parameter(s) do I use for this function or is there a better method?
}

12-28-2001

Engineer

You can pass whatever system command you want with the system() function.

As a parameter you pass it the command:

system("cd my_directory"); // will actually execute that command in the system

12-28-2001

Engineer

Thought of something to add:

Just think of the system() function as you being in a command prompt window or a system terminal.

In Unix for example you would type "ls -al" to get a long listing of the current directory showing all the files. In order for you to do the same thing from your program you can write the following:

#include <stdlib.h>

int main()
{
system("ls -al);
return 0;
}

After you run it, it should do the same thing......

Cheers

12-28-2001

RpiMatty

The solution is to read the file line by line, printing out each line, and pausing after 50-100 lines, whatever pleases you