Apr 29, 2010 at 3:49am UTC
How do i set the output to: each string character + number( encryption code input by user)
EX: A(ASCII =65)
17( input by user)
output: R (ASCII 82)
Here is my program, but I only got increase by 1. not by the input number
void encrypter( char *, int);
void decrypter( char *, int);
int main()
{
int n;
const int code=100;
char string[code];
cout<<"**** ENCRYPTER ****\n";
cout<<"\n Insert the secret sentence: ";
cin.getline(string,code);
cout<<"\n\n Insert the encrypting code <1-100>: ";
cin>>n;
encrypter(string,code);
cout<<"The encrypted sentence is: "<<string<<endl;
decrypter(string,code);
cout<<"\n\n\n**** DECRYPTER ****";
cout<<"\n\n Insert the code: ";
cin>>n;
cout<<"\n The decrypted sentence is: "<<string;
cout<<endl<<endl<<endl;
return 0;
}
void encrypter(char string[], int n)
{
for (int i=0;string[i] !='\0';++i)
string[i]++;
}
void decrypter(char string[], int n)
{
for(; *string !='\0';++string)
--(*string);
}
Apr 29, 2010 at 4:23am UTC
Thank you very much!!!!!!!! It works