char arrays/encryption/decryption help!!

The program I'm writing needs to encrypt and/or decrypt a message entered by the user. It's suppose to get all of the message's odd characters and all of the even characters separately, then output them together in one message.

ex:
"I love programming!"
Encrypted message:
"Ilv-rgamn!-oepormig"
(the spaces should be dashes)

This is the code I have so far, we're also not allowed to use any strings, just character arrays.

Can anyone help me to even start the encryption function?? I'm pretty lost at the moment...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;

int display_menu(int display)
{
  int choice;

  cout << "Menu: " << endl;
  cout << "Enter the number then hit return." << endl;
  cout << "1. Encrypt a Message" << endl;
  cout << "2. Decrypt a Message" << endl;
  cout << "3. Quit" << endl;
  cin >> choice;

  switch(choice)
    {
    case 1: cout << "Ecrypt" << endl;
      break;
    case 2: cout << "Decrypt" << endl;
      break;
    case 3: cout << "Thank You, Goodbye!" << endl;
      break;
    default: cout << "Error, not an option." << endl;
      return display_menu(choice);
    }
  return(choice);
}

void encrypt_message(char encrypted[])
{
  for(int i = 0; i < 100; i++)
  {
 encrypt_message[i + 2];
  }
}

void decrypt_message(char decrypted[])
{
  for(int i = 0; i < 100; i--)
    {
      decrypt_message[i + 2];
    }
}

int main()
{
  char message[100];
  display_menu(choice);

  if(choice == 1)
    {
      cout << "Enter your message: " << endl;
      cin >> message;
      encrypt_message(message);
      cout << "Your encrypted message is: " << endl;
      cout << message << endl;
    }

  if(choice == 2)
    {
      cout << "Enter your message: " << endl;
      cin >> message;
      decrypt_message(message);
      cout << "Your decrypted message is: " << endl;
      cout << message << endl;
    }

  if(choice == 3)
    {
      return 0;
    }
  return 0;
}
Topic archived. No new replies allowed.