Trying to create a Caesar Cipher that ciphers and deciphers. I keep getting errors and I try and fix it and I need help here is the program that I have so far.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int main ()//Caesar Cipher
{int choice;
int flag;
char word[140];
char new_word[140];
int Letter_Amount;
int shifts//according to the directions the cipher is a shift 3
char; alphabet[27] = {'a'; 'b'; 'c'; 'd'; 'e'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; 'n'; 'o'; 'p'; 'q'; 'r'; 's'; 't'; 'u'; 'v'; 'w'; 'x'; 'y'; 'z'};//declaring that the variables which in this case would be the alphabet
char new_alphabet[27];
bool flag=false;
bool flag_2=false;
do; {//choice menu for the program
cout <<"Ceaser Cipher v2.0"<<endl; //would have spelled it Caesar Cipher but I want to make sure it matches the program
cout <<"1. To input/modify input data"<< endl;
cout <<"2. To cipher a message"<< endl;
cout <<"3. To decipher a message"<< endl;
cout <<"4. To perform a statistical analysis of the text."<< endl;
cout <<"Press 0 to quit."<< endl;
cout <<"Please choose:";
cin >> choice;
if(choice==0) cout <<"Now quitting.."<< endl;
else if (choice==1){
if (flag_2==false){
cout <<"Give input count"<< endl;
cin >> Letter_Amount;
cout <<"Please give text:";
for (int i=0; i<Letter_Amount; i++){
cin >>word[i];
}
cout<<endl;}
else if { cout <<"Are you sure you want to modify the input?"<< endl;
cin >>Answer;
if(Answer=='n'){
cout <<"Returning to the main menu..\n\n";}
else if(Answer=='y'){cout <<"Give new input count:";
cin >>Letter_Amount;
cout <<"Please give new text:";
for (int i=0; i<Letter_Amount; i++){
cin >>word[i];}
}
else cout <<"Please choose Y(es) or N(o).\n";}
flag=true;
flag_2=true;}
else if(choice==2){
if(flag){
cout <<"Please choose the number of shifts you want:";
cin >>shifts;
for(int i=0; i<26; i++){
if(i shifts>=0){
new_alphabet[i]=alphabet[i shifts];}
else if{
new_alphabet[i]=alphabet[26 +i shifts];
}}
cout <<new_word;
}
else if cout <<"Please use option 1 before using this one.\n\n";}
else if (choice==3){
if(flag){ cout <<"Option 3 is still under progress.\n\n"<< endl;}
else if cout <<"Please use option 1 before using this one.\n\n"<< endl;}
else if (choice==4){ if(flag){
cout <<"Option 4 is still under progress.\n\n"<< endl;}
else if cout <<"Please use option 1 before using this one.\n\n"<< endl;}
} while (choice!=0);
return 0; }
@kkenner
You have a lot of things wrong with the program, as it stands.
int shifts ( needs semi-colon )
char ; Alpahabet[27] ( needs NO semi-colon after char, and you need to change the semi-colons between the
letters of the alphabet, to comma's )
do; ( does NOT need semi-colon )
else if ( you're not checking an if, so you probably meant just, else. ie : cout << "text" if first else if fails )
flag ( redefined. You have int flag, and bool flag )
Answer ( undefined. Need to declare char Answer; )
New_Word ( You never add anything to New_Word, so there isn't anything there )
i shifts ( Don't know what that is. You can't have both variables in a single set of brackets )
( The same for the 26 + i shifts . Illegal )
After making the changes, I got your program semi-running, though I didn't get the new_alphabet array to print correctly. But at least you'll be on the right track.