Apr 18, 2011 at 11:37am UTC
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;
}
Apr 18, 2011 at 12:03pm UTC
if input[counter] = input[counter] + 20;
is the "encoding" then it's pretty easy to write the decodeer, go on... have a go :-)
Apr 18, 2011 at 6:43pm UTC
Ohhh the problem i know very little C++ , can any make that for me please..Complette please..
Apr 19, 2011 at 6:32pm UTC
Have a go at coding it rami, it's really simple.
if decode is the opposite of encode
what is the opposite of +20; ?
Apr 20, 2011 at 5:03am UTC
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;
}