#include "stdafx.h"
#include <iomanip>
#include <iostream>
#include <string>
#include <cstdlib>
usingnamespace std;
int main()
{
// variables
string password = "";
string guess = "";
string attempt = "";
cout << "Enter a password using any characters from [a-z, A-Z, !, @, #, $, %, &]";
cout << endl << "Password: ";
getline(cin, password);
system("cls");
while (guess != password)
{
cout << "What is the password you entered?: ";
getline(cin, guess);
cout << endl;
cout << "Password: ";
for (int i = 0; i < password.length(); i++)
{
guess.substr(0,i) = password;
attempt = password;
cout << attempt;
}
cout << endl << "You entered: " << guess << endl;
if (guess.length() != password.length())
{
cout << "Password length does not match!" << endl;
}
cout << endl;
}
cout << "You guessed the right password!" << endl;
return 0;
}
only trouble I'm having is with the substr function. I am trying to compare each letter of the guess to the original password and have no idea what I'm doing with that for loop