help: want decode

hello there is only encode , can any one make the versa Decode:


#include <iostream>
#include <string>
#include <fstream>
#include <cstring>

using namespace std;


string getuserinput();
string encode(string input);
void output(string input);
int moreinput();

int main()
{
string input;
int option;

//cout << "This program will encode the strings that you input. " << endl;


do
{

input = getuserinput();

cout << strlen(input.c_str());

input = encode(input);

output(input);

option = moreinput();

}
while (option == 1);

system("pause");

return 0;
}





string getuserinput()
{
string input;

cout << endl << "Please enter a sentence: ";

getline(cin,input);

return input;
}


string encode(string input)
{
int counter=0;

while (counter < (strlen(input.c_str())))
{
input[counter] = input[counter] + 20;
cout << endl << input[counter];
counter++;

}

return input;
}

void output(string input)
{
ofstream myFile;

myFile.open("code.txt");

for (int counter = 0; counter < (strlen(input.c_str()));counter++)
myFile << input[counter];


myFile.close();


}


int moreinput()
{
int option;

//cout << endl << "Do you want to enter another? 1 for yes or 0 for no: ";

//cin >> option;

return option;

}
if input[counter] = input[counter] + 20; is the "encoding" then it's pretty easy to write the decodeer, go on... have a go :-)
I sure can!
Ohhh the problem i know very little C++ , can any make that for me please..Complette please..
Have a go at coding it rami, it's really simple.

if decode is the opposite of encode
what is the opposite of +20;?
ok maybe i have it now, when es SO what u have mean.....
now have this error : -->292: error: a function-definition is not allowed here before '{' token
292:error: expected `,' or `;' before '{' token

and line 292 is this : { --> the second line here



string decode(string input)
{
int counter=0;

while (counter < (strlen(input.c_str())))
{
input[counter] = input[counter] - 20;
cout << endl << input[counter];
counter++;
}
return 0;

}
Topic archived. No new replies allowed.