/* Programmer: Jennifer Leopold Date: November 1, 2015
File: hw1_main.cpp
Purpose: Program that encrypts a file of text (or input
from the keyboard) by modifying certain letters
and inserting various phrases.
To compile: fg++ hw8_main.cpp hw8_functs.cpp -o hw8
To execute: ./hw8
*/
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include "hw8_functs.h"
using namespace std;
int main()
{
SentenceInfo s;
ifstream fin;
ofstream fout;
bool inputFromKeyboard;
// Seed the random number generator
srand(time(NULL));
// Open data files
openInputFile(fin, inputFromKeyboard);
fout.open(OUTPUT_FILENAME);
do
{
// Get input for a sentence and break it into words
if (inputFromKeyboard)
getSentence(s, cin);
else getSentence(s, fin);
if (s.numWords != 0) // True if end-of-file
{
// Encrypt the sentence
transformSentence(s);
// Output the sentence
fout << s;
}
} while (s.numWords != 0);
// Close files
if (!inputFromKeyboard)
fin.close();
fout.close();
// Sign-off
cout << "\nEncrypted file " << OUTPUT_FILENAME
<< " has been created.\n";
return 0;
}