alright I need help and at this point I am desperate. Been working on this for a couple of days, mostly typing and then hitting the Edit/undo! This is a homework project. What the project is supposed to do is:
1. open a text file(einstein.docx)
2. Prompt user for a key(entire alphabet randomly input)
3. encrypt to a file named by user
4. decrypt and write to a file named by user
5. also display the enc/dec on screen
I had the encrypt and decrypt working for a single sentence that was previously typed in to the program. it displayed properly. Teacher always told us, get one thing working then add the variables. That's where the trouble started.
I don't normally beg, but I am desperate,I've got a paper to write for another class and I'd like to see my daughters softball game!
Here's what I have:
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
using namespace std;
void encrypt( char userinput[ ] ); // prototypes of functions used in the code
void decrypt( char * ePtr );
int main( )
{
char userInput[26], inputFileName[1000],encryptionFileName [1000],temp[1000], outputFileName[1000] ;
ifstream einstein;
ofstream encryptionFile;
ofstream outputFile;
{
vector<string> text_file;
ifstream ifs( "einstein.docx" );
string temp;
while( getline( ifs, temp ) )
text_file.push_back( temp );
}
cout << "input string:";//user input, random alphabet
cin >> userInput[26];
einstein.open(inputFileName, ios::in);//open file to be encrypted
cout << "Enter the name of an encryption file: ";
cin >> encryptionFileName;// file for encrypted file to be sent to
cout<< "enter the name of an output file: ";
cin >> outputFileName;// file for decrypted file to be sent to.
encryptionFile.open(encryptionFileName, ios::out);
outputFile.open(outputFileName, ios::out);
char string[1000] = string;
cout << "Original string is: " << string << endl;
encrypt( string );
// call to the function encrypt( )
cout << "Encrypted string is: " << string << endl;
decrypt( string );
// call to the function decrypt( )
cout << "Decrypted string is: " << string << endl;
system("PAUSE");
return 0;
}// main
//encrypt data
void encrypt (char userInput[] )
//char userinput;
{
char userinput[26];
for( int i=0; userInput[i] != '\0'; ++i ) ++userInput[i];
} // encrypt
//decrypt data
void decrypt( char * ePtr )
{
for( ; * ePtr != '\0'; ++ ePtr ) --(* ePtr);
}
I will add the write to encryption /decryption file code later.
Again, Thank You for any assistance. It is appreciated.