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.

One thing you did not have is code-tags. Push the button and then paste your code. You are then more likely to get help as your code is enormously more understandable and faster to read.

#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);

}

Thank you.

This does not look correct to me (but maybe I am rusty): you shadow the parameter with second definition inside function definition:

void encrypt (char userInput[] )
//char userinput; 
{
     char userinput[26];

This looks like old Kernighan Richie style pre-Ansi style, but then there would not be any definition in parameter list.

Error log you should have included, from Code::Blocks:

||=== crypt, Debug ===|
K:\cpp\crypt\crypt\main.cpp||In function 'int main()':|
K:\cpp\crypt\crypt\main.cpp|36|error: array must be initialized with a brace-enclosed initializer|
K:\cpp\crypt\crypt\main.cpp|44|error: 'system' was not declared in this scope|
K:\cpp\crypt\crypt\main.cpp|10|warning: unused variable 'temp'|
K:\cpp\crypt\crypt\main.cpp||In function 'void encrypt(char*)':|
K:\cpp\crypt\crypt\main.cpp|52|warning: unused variable 'userinput'|
||=== Build finished: 2 errors, 2 warnings ===|

Here's what I got for errors, thusfar!

G:\final final\finalProject2.cpp In function `int main()':
37 G:\final final\finalProject2.cpp invalid initializer
G:\final final\Makefile.win [Build Error] [finalProject2.o] Error 1

I noticed that I missed that the internal variable has input with small 'i' and is not same as parameter. Still mthe purpose of it I do not understand as it is never used. it is not good naming practice to have variable names so close to each other.

You have error message, mine was even clearer than your compilers. So fix the initializer.

This is not the preferred way to get a character and it won't work if you are actually trying to get a string:

cin >> userInput[26];

It should be:

cin >> userInput; // Get a string

Or this:

cin.get( userInput[26] ); // Get a character.

Also, what is this?? This isn't correct either. I am not even sure what you are trying to do here.

char string[1000] = string;

fixed the initializer, and changed the cin to
cin.get( userInput[26] );
it compiles and I can run through the steps in the command window, but if I type more than one character when it requests string it jumps past the request for encryption file, otherwise if i only put in one character I get what I can only describe as the symbol on green lanterns shirt for the three outputs.
as for the Whats this?
that was an attempt to initialize the size of the string that was going into the encryption loop

Sorry, I am new at this.

can you describe what the line 59 is supposed to do. The style looks esoteric to me.

The original basic part of the program that worked, added 1 integer to the original text, this line subtracted one using a pointer

Please re-post your updated code

Here it is

#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.get( userInput[26] );

	einstein.open(inputFileName, ios::in);//open file to be encrypted

	cout << "Enter the name of an encryption file: ";
	cout <<endl;
	cin >> encryptionFileName;// file for encrypted file to be sent to
    cout<< "enter the name of an output file: ";
    cout<<endl;
    cin >> outputFileName;// file for decrypted file to be sent to.
	encryptionFile.open(encryptionFileName, ios::out);	
    outputFile.open(outputFileName, ios::out);


char string[1000] = {};
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);

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.