SOURCE FILE: makeList.cpp
/*
This program generates a file containing a series of
six-digit, non-negative numbers. It asks you how many numbers
you want and it asks you for a file name. It then writes the
desired number of integers into the file, one number per line.
WARNING: if the file name you give is the name of a file that
already exists, that file will be destroyed.
*/
#include <fstream.h>
#include <stdlib.h>
#include <time.h>
#include <string>
int main()
{
int howMany ;
string fileName ;
cout << "Enter the number of integers you would like to generate: " ;
cin >> howMany ;
cout << "Enter the name of the file to put the integers in: " ;
cin >> fileName;
ofstream outFile(fileName.c_str()) ;
srand(time(NULL)) ;
int i, j ;
for (i=1; i<=howMany; i++)
{
for (j=0; j<6; j++) outFile.put('0' + rand()%10) ;
outFile.put('\n') ;
}
return 0 ;
}