rendered paste body#include <iostream>
#include <string>
using namespace std;
int Translator(int Choice);
string myreplace(string s,char* a,char* b);
int main()
{
int Choice;
string Leet;
int Outcome;
cout << "Hello. What would you like to do: ";
cout << "\n1 - Normal to leet\n";
cout << "2 - leet to Normal\n";
cin >> Choice;
Outcome = Translator(Choice);
int x;
cin >> x;
return 0;
}
int Translator(int Choice)
{
int LorN;
string Leet;
switch(Choice)
{
case 1:
cout << "What is your sentence?: ";
cin >> Leet;
LorN = 1;
myreplace(Leet, "e", "3");
myreplace(Leet, "a", "@");
break;
case 2:
cout << "What is your sentence?: ";
cin >> Leet;
LorN = 2;
break;
default:
cout << "this isnt an option please choose again.";
}
/*
if (LorN == 1)
{
for (int x = 0; x < Leet.length(); x++)
{
if(Leet.find_first_of("e") == string::npos)
{
cout << "no e's....";
}
else
{
Leet.replace(Leet.find_first_of("e"), 1, "3");
}
}
}
else
{
if (LorN == 2)
{
cout << "ok in a sec.";
}
}
*/
cout << Leet;
}
string myreplace(string s,char* a,char* b)
{
int loc;
while(loc = s.find(a)) // loop until its not found
{
if(loc == string::npos)
break;
s.replace(loc,strlen(b),b);
return s;
}
}