#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
void Removespaces(char clear[], char cipher[],int x,int i);
void Removevowels(char clear[],char cipher[],int x,int i);
int main()
{
char clear[256];
char cipher[256];
int x,i;
int opt;
cout<<"Encryption (1) 0r Decryption (2):"<<endl;
cin>>opt;
cin.ignore();
if(opt==1)
{
cout<<" Enter a string(sentence):";
cin.getline(clear,sizeof(clear)); // calling the string(sentence)
x = strlen(clear);
for(i=0;i<=x-1;i++) // for loop for Encrypting string(sentence)
{
cipher[i] = clear[i]+3;
}
cipher[x] = '\0';
cout<<" Encrypted:"<< cipher << endl;
if(opt==2)
{
cout<<" Enter a string(sentence):";
cin.getline(cipher,sizeof(cipher));
x = strlen(cipher);
for(i=0;i<=x-1;i++) //for loop for Decryption
{
clear [i] = cipher [i] -3;
}
clear[x] = '\0';
cout <<"Decrypted String:" << clear << endl; // Decrypted string(sentence)
}
}
system("pause");
return 0;
}
void Removespaces(char clear[],char cipher[],int x,int i)
{
if (isspace(clear[i]))
{
cipher[i] = clear[i];
}
else
{
cipher[i] = clear[i]+3;
}
}
}
for(i=0;i<=x-1;i++)
{
if(cipher[i]!=' ')
{
cout<<cipher[i]<< endl;
}
}
void Removevowels(char clear[],char cipher[],int x,int i)
{
for(i=0;i<=x-1;i++)
{
if (cipher[i]=='a' || cipher[i]=='e' || cipher[i]=='i' || cipher[i]=='o' || cipher[i]=='u' || cipher[i]=='A' || cipher[i]=='E' || cipher[i]=='I' || cipher[i]=='O' || cipher[i]=='U') {
cipher[i]=' ';
}
cout<<cipher[i];
}
}
hey guys i never used functions before and i'm new to C++, so any help and advice is very welcome. my program gives two options 1 encrypt a string and 2 decrypt. i'm trying to sort option one first it encrypts the string but i want the functions preserve the whitespaces and then remove and next function to remove vowels.cheers in advanced guys hope you can help.