tom12 0 Light Poster

Hey folks in my program is to encrypt a string.i then declared a function outside of the program to preserve the spaces which have been encrypted. but i dont know how to return my function to the main program to output the encrypted string with the spaces. cheers guys hope you can help.

#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;
int RemovedSpaces ;

cout<<"Encryption (1) 0r Decryption (2):"<<endl;
cin>>opt;
cin.ignore();
if(opt==1)
{
    

cout<<" Enter a string(sentence):";
 cin.getline(clear,sizeof(clear)); 

x = strlen(clear);

for(i=0;i<=x-1;i++)            
{
cipher[i] = clear[i]+3;
}
cipher[x] = '\0';

cout<<" Encrypted:"<< cipher << endl;
cout<< " preserved spaces :"<<cipher[i]<<endl;  //trying to return function example1
 
                
if(opt==2)
{
cout<<" Enter a string(sentence):";
 cin.getline(cipher,sizeof(cipher));
  

x = strlen(cipher);
for(i=0;i<=x-1;i++)                               
                   {
                   clear [i] = cipher [i] -3;
                   }
clear[x] = '\0';
cout <<"Decrypted String:" << clear << endl;       
}
}



system("pause");
return 0;
}



void RemovedSpace(char clear[], char cipher[],int x,int i)

{ 
     for(i=0;1<=x-1;i++)
     {
     if (isspace(clear[i]))
    {
        cipher[i] = clear[i];
    }
    else                                     
    {
       cipher[i] = clear[i]+3;
    }
}
return cipher[i] ;                  // i need to return this function back up  to(Example 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.