//Encryption/decryption program that encrypts or decrypts
//user input as a string.

#include <iostream>
#include <string>

using namespace std;

string encrypt(string text, string message);
string decrypt(string text, string message);

char choice;

int main()


	{


//Ask user to encrypt or decrypt

  		cout << "Would you like to encrypt or decrypt?" << endl;
		cout << "Enter E for encrypt or D for decrypt." << endl;
			  cin >> choice;


  if ((choice == 'E')||(choice == 'e'))
  {

		encrypt(string text, string message); //error point to here

  }
 else if ((choice == 'D')||(choice == 'd'))
  {
  		decrypt(string text, string message); //error point to here
  }

			  return 0;
}

//Encrypt the text
string encrypt(string text, string message);

  		{
		int i;
   	string temp;


		cout << "Enter the text you wish to encrypt." << endl;
		cin >> text;


		for (i = 0; i < message.length(); ++i)
      temp += 3 + (text[i] - '0');

		cout << "Encrypted text is " << temp << endl;

		}

//Decrypt the text
string decrypt(string text, string message);

  		{
		int i;
   	string temp;


		cout << "Enter the text you wish to decrypt." << endl;
		cin >> text;


		for (i = 0; i < message.length(); ++i)
      temp += 3 + (text[i] - '0');

		cout << "Decrypted text is " << temp << endl;

		}

error: expected primary-expression before "text"
error: expected primary-expression before "message"


Can guide me? Thanks in advance!

Edited 6 Years Ago by Nick Evan: Replaced tags

There are quite a few errors in the program. Firstly, you don't mention the data type when you call a function.

So, in your function main:-

encrypt(string text, string message)

is incorrect.

It should be

encrypt(text, message)

And more importantly, you haven't declared text and message!

Thanks! for those error correct.

char choice, text;
string encrypt, message;

i just edit the declare for text and message. but still unable.. where did i done wrong? Sry, just start learning last few day.

Hope u able to guide me again. thanks!

This article has been dead for over six months. Start a new discussion instead.