Need help storing user's input

My assignment is to take a string that a user enters and change all the characters in the string in order to encode or decode their input. The user has to put in an integer that is the "key". My code is nowhere near being finished. At the moment I am simply asking them to type Encode (so they go to the encode part of my program--otherwise they'd simply quit)

My problem was that I was trying to store their input with the cin part and when I run the program (I'm trying to store it in the class) it isn't giving me the option to input anything until I get to the integer part.

I changed it a bit and added the class at the top and now it wont compile at all. It says "expected primary expression before "else" " at line 57.

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
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;


class Encoder
{
      private:
              char phrase;
              char encodedphrase;
              
      public:
             
             void StorePhrase()
             {
                  cout << "Enter a the phrase you would like to encode:" << endl;
                  cin >> phrase;
             }
             
           
             
};               
                  
int main()
   {
          
   Encoder one;
   
   string word; 
   int key = 0;
   char command, Encode, Decode, Quit;
   
   cout << "Welcome to the Caeser Encoder/Decoder!" << endl;
   cout << "Would you like to Encode or Decode or Quit?" << endl;
   cin >> command;
   
   if (command = Encode)

   {
   one.StorePhrase();
   
   
   
   cout << "Enter an integer shift key between 0 and 20: " << endl;
   cin >> key;
   int wlen = word.length();     //length of string object

   cout << "Your encoded phrase is:" << endl;
   for(int j=0; j<wlen; j++) {
	   word.at(j) = word.at(j) + key;
   

   cout << word << endl;
   };
   
   else 
   cout << endl;

   system("pause");
   return 0;
   }
" else
cout << endl;"

is outside of your {block}
Sure you forgot to close the if block before bringing the else.

Aceix.
Oh wow, I counted and double counted my brackets, can't believe I missed that. Thanks!
Topic archived. No new replies allowed.