I/O txt file help

I have a program, that i creatd a text.. but i dont know how to display 18 lines (no less or no more). I have been given a random number generator.
Here is my code, can anyone help me please?

creates a text file named points.txt (in the default directory, overwrite it if it already exists) and writes EXACTLY eighteen lines, no more, no less. Each line is to have exactly four floating point numbers. Each number MUST be randomly generated by calling the inline function random(). Calling srand, as shown below, seeds the random number generator so you get different numbers each time you run your program. srand need only be called once at the start of the main program. Use default precision and format for the output to the file.

inline double random( void )
{return ((RAND_MAX/2.-rand())/1000.);}


int main( )


{
srand( (unsigned)time(NULL) );/* Seeds random-number generator with current
time so numbers will be different every time it is run. */

string filename = "points.txt"; // put the filename up front
ofstream outFile;

outFile.open(filename.c_str());

if (outFile.fail())
{
cout << "The file was not succesfully opened" << endl;
exit(1);

}
// set the output file stream formats
outFile << setiosflags(ios::fixed)
<< setiosflags(ios::showpoint)
<< setprecision(4);

// set data to the file
if (random())

outFile.close();
cout << "The file " << filename
<< " has been successfully written." << endl;




ofstream myfile;

myfile.open ("point.txt");
myfile << "Writing this to a file.\n";
myfile.close();



return 0;
}
[1858 byte] By [Daywalker-] at [2007-11-20 11:56:04]
# 1 Re: I/O txt file help
for(int line = 0; line < 18; ++line)
{
for(int i = 0; i < 4; ++i)
{
float value = ...
outFile << value << ' ';
}
outFile << std::endl;
}
cilu at 2007-11-11 4:02:07 >
# 2 Re: I/O txt file help
Alright thanks, i had a similar way.. reassured it working.
Another question if i needed the program to get from the user the name of a text file like the one created, but with any number of lines, and reads the file, treating each line as containing (in this order) the (x1,y1) and (x2,y2) coordinates of two points, respectively. Then, for each line, displays on the screen in tabular form: the number of the line analyzed (starting at 1), and the coordinates of the midpoint of the line joining the two points; all on one line. Also getting the program to keep reading lines until the end of the file is reached and should not need to be given the number of lines in the file (by the programmer or the user).
Daywalker- at 2007-11-11 4:03:12 >