I have recently started learning C++, and I have decided to create a basic password-cracking console program. In it, the user inputs a character, and the program tries to guess what character the user entered by starting at the 32nd ASCII character and going up to the 126th, checking along the way to see if the ASCII character matches with the user's character. If it matches, it tells the user.
Now, I want to upgrade my program from a character to a string. I want the user to input a string, and then for the program to guess it. However, I have no idea how to do this. I have tried searching for an answer online, but to no avail.
Thanks in advance!
#include <iostream>
int main()
{
using namespace std;
char Password;
char C1;
cout << "Input a character to crack." << endl;
cin >> Password;
for (C1 = 32; C1 < 127; (int)C1++) {
printf("Trying %d\n", C1);
if (C1 == Password) {
cout << "The password is " << C1 << "." << endl;
break;
}
}
system("PAUSE");
return 0;
}