how in this program can i make it encrypt all words you enter not just 1
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
cout << "enter a password you want to encrypt,it has to be only letters: ";
cout << endl;
string c;
cin >> c;
for (int i = 0; i<c.size();i++)
{
c[i] = tolower(c[i]);
c[i] = c[i]-2;
if (c[i]<97)
{c[i] = c[i]+26;}
}
cout << c << endl;
system("pause");
return 0;
}
i did that and it worked but when i ran the program and entered the sentence but every where there was a space their was and 8 so say i put hi i am moot it says "fg8g8yk8kyrr" how do i get rid of the 8
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
cout << "enter a password you want to encrypt,it has to be only letters: ";
cout << endl;
string c;
getline(cin, c);
for (int i = 0; i<c.size();i++)
{
c[i] = tolower(c[i]);
c[i] = c[i]-2;
if (c[i]<97)
{c[i] = c[i]+26;}
}
cout << c << endl;
system("pause");
return 0;
}
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
cout << "enter a password you want to encrypt,it has to be only letters: ";
cout << endl;
string c;
getline(cin, c);
for (int i = 0; i<c.size();i++)
{
c[i] = tolower(c[i]);
c[i] = c[i]-2;
if (c[i]<97)
{c[i] = c[i]+26;}
}