Ok, there is no error code, the option to build and run is light gray (un-selectable) and the code is:
// 07 July 2011
#include <string>
#include <iostream>
using namespace std;
// Encryption code
void enc(string& s, int shift[], int numshift){
for (unsigned i = 0; i < s.length(); ++i){
if (s >= 97 && s <= 122){
s -= 'a';
s = (s + shift[i%numshift] + 26) % 26;
s += 'a';
}
if (s >= 65 && s <= 90){
s -= 'A';
s = (s + shift[i%numshift] + 26) % 26;
s += 'A';
}
}
}
// Decryption code
void dec(string& s, int shift[], int numshift){
for (unsigned i = 0; i < s.length(); ++i){
if (s >= 97 && s <= 122){
s -= 'a';
s = (s - shift[i%numshift] + 26) % 26;
s += 'a';
}
if (s >= 65 && s <= 90){
s -= 'A';
s = (s - shift[i%numshift] + 26) % 26;
s += 'A';
}
}
}
int main(){
// Variables
int numshift;
char choice;
int* shift;
string input;
// Input/Output Code
do{
// prompts user to enter encryption or decryption choice
choice='?';
cout << "Encrypt (E) or Decrypt (D)?: ";
cin >> choice;
// Encrypt/decrypt selection error checking
if (choice!='d'&&choice!='D'&&choice!='e'&&choice!='E'&&choice!=' '){
do{
cout << "Please re-enter your selection: ";
cin >> choice;
}while(choice!='d'&&choice!='D'&&choice!='e'&&choice!='E'&&choice!=' ');
}
// User selects the number of shift values he/she wants
cout << "Enter the number of shift values. ";
cin >> numshift;
shift=new int [numshift];
// User enters shift values
for(int i=0; i<numshift; i++){
cout << "Input value of shift #" << i+1 << ": ";
cin >> shift;}
// Input/ output codes
while(choice==' ');{
switch(choice){
case 'e':
case 'E':
// Encryption input/output
cout << "Enter text to be encrypted: ";
cin.ignore(1);
getline(cin,input);
enc(input, shift, numshift);
cout << "Here is your encrypted text: " << input << endl << endl;
break;
case 'd':
case 'D':
// Decrytpion input/output
cout << "Enter text to be decrypted: ";
cin.ignore(1);
getline(cin,input);
dec(input, shift, numshift);
cout << "Here is your decrypted text: " << input << endl << endl;
break;
case ' ':
break;
}
}
// deletes array to prepare for next loop
delete[]shift;
}while(true);
}