I/O txt file help
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;
}

