NEED HELP!! URGENT!!

Hello.
I have this code that has been killing me.
Any and all help is appreciated.
Its a cipher and for some reason it won't work.
It opens and asks for user input but doesn't execute anything correctly.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{	char a;
	char cipher (char);
	string input;
	string filename;
	string ofilename;
	string line;
	ifstream infile;
	ofstream outfile;

	cout<<"Enter 'e' to encrypt/Enter 'd' to encrypt: ";
	cin>>a;
	
	if (a=='e'||a=='E') {
			
			
			cout << "Input filename: ";
			cin>>filename;
			infile.open(filename.c_str());

			if (!infile.is_open()) {
				cout<<"file cannot be opened"<<endl;
				return 0;
			}				
				
			cout<< "Output filename: ";
			cin>>filename;
			outfile.open(filename.c_str());
		
					
			do {
			getline (cin,line);
			string output = "";
			for(int x = 0; x < input.length(); x++) {
			
            output += cipher(input[x]);
			}
			cout<<output<<endl;
			outfile<<output;
			}while (!input.length() == 0);
		}

	else if (a=='d'||a=='D'); {
			
				
			cout << "Input filename: ";
			cin>>filename;
			infile.open(filename.c_str());

			if (!infile.is_open()) {
				cout<<"file cannot be opened"<<endl;
				return 1;
			}				
			
				
			cout<< "Output filename: ";
			cin>>filename;
			outfile.open(filename.c_str());
		
			
			do {
			getline (cin,line);
			string output = "";
			for(int x = 0; x < input.length(); x++) {
			
            output += cipher(input[x]);
			}
			cout<<output<<endl;
			outfile<<output;
			}while (!input.length() == 0);
		}
	}

char cipher (char c) {

			if (isalpha (c))	
	{		c = toupper(c);
			c = (((c-65)-5) % 26) + 65;
	}
			system ("pause");
			return c;
}
Topic archived. No new replies allowed.