Pointer to string

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);
}
1
2
3
4
void encrypter(char string[], int n) {
    for (int i=0;string[i] !='\0';++i)
        string[i]+=n;
}


then call it like
encrypter(string,n);
Thank you very much!!!!!!!! It works
Topic archived. No new replies allowed.