SOURCE FILE: makeList.cpp
/*
This program generates a file containing a series of eight-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 pre-existing file will be destroyed.
*/
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
#include<iomanip>
#include <time.h>
using namespace std;
const int numDigits = 8 ;
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<numDigits; j++) outFile.put('0' + rand()%10) ;
outFile.put('\n') ;
}
return 0 ;
}