my encoder will not encode anything after it sees a space I used the getline function but that doesnot help if my phrase is welcome here the only thing encoded is welcome.
# include <iostream>
# include <string>
using namespace std;
int main()// declaration of main
{
char first,last, b;//declaration of char variables
bool pass=false, found = false;//declaration of bolean values
int a,length,count; //declaration of int varibles
string code;// declaration of string
while (pass==false)//declaration of while loop
{
cout << "\nThis program will encrypt the entered text using Caesar Cipher." << endl;
cout<< "Please input the fisrt letter of the alapabet to begin encoding from(a-z)then press enter\n"; //output statememt
cin>> first;//input statement
cout<<"Please enter the last letter of the alaphabet that you wish encoding to stop then press enter(a-z)\n";// output statement
cin>> last;//input statement
if ( isalpha(first)&& isalpha (last))//decalaration of if statement
{
pass=true;// declaration of test statement
}
else
{
cout<<"Invalid statement please enter a alaphabet between (a-z)\n";//declaration of output statement
}
}
label:// declaration of a label
cout<<"Please enter the amount you want the code to shift by(number 1-24)\n";//declaration of output statement
cin>> a; // input statement
cout<<"Please enter text that you wish to be encoded\n";//declaration of output statement
cin>>code;//declaration of input statement
getline(cin,code);
length = (int)code.length();// set the length to however long the input is calling its member function
for ( count = 0; count < length; count++)// declation of for loop
{
if ( isalpha(code[count]))//declaration of character if statement
{
for ( int i=0; i < a; i++) //declaration of for loop
{
if( code[count]=='z' && last != 'z')
{
code[count]='a';
code[count]++; // else continue to alphabet
}
else
{
if( code[count]=='z' && last == 'z')
{
code[count]=first;
code[count]++; // else continue to alphabet
}
else
{
if(code[count]==last)// when the character reaches Z the next character would be a
{
code[count]=first;
}
else
{
code[count]++;
}