aaa

you aren't using parameters...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int select_key();
//consider `string encrypt_cipher(int key, string message)' to avoid i/o in the function
void encrypt_cipher(int key); 

int main(){
  int key = 0;
  do{
    //...
    key = select_key();
    //...
    encrypt_cipher(key); //consider passing the message as a parameter
  }while(selection != 4);
}

int select_key(){
  //...
  return key;
}



> if (toupper(a[i]))
no idea what you try to do there
if you want to convert it to uppercase, use a[i] = toupper(a[i]);
if you want to check that it is a letter, use if (isalpha(a[i]))

> result += char(int(a[i] - 65 + key) % 26 + 65);
don't bother to memorize the ascii table, let the compiler do the translation
you may write a[i] - 'A'
Registered users can post here. Sign in or register to post.