Programming help

Pages: 12
I need to make a program that is able to take in a 4 letter uppercase password, and then it will go into a loop that will start at AAAA...AAAB...AAAC...AAAD...etc until it reaches the input.
If this isn't an assignment... Why?

If this is an assignment, then what have you written so far?
make 4 loops looping each position
This is an assignment, and heres what i have so far:
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
system ("Color 2");
char password[5];
char "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z";
cout << "Please enter a five digit letter only password:";
cin >> password;
-----------------------------------------------------------------------------------------------------------------------
for(int i = 'A'; i < 'Z' + 1; ++i)
if (frequency_table[i] != 0)
std::cout << (c = i) << ": " << frequency_table[i] << '\n';

I know that I need to use the code under the dashes somewher but im not sure how or where
And Armon safii its not that easy becuase you cannot make a for loop counter with letters. I need to be able to convert the letters into numbers which is what the code under the dashes needs to do.
Please edit your post and make sure that your code is [code]between code tags[/code] so that it has syntax highlighting and line numbers.
I need to make a program that is able to take in a 4 letter uppercase password, and then it will go into a loop that will start at AAAA...AAAB...AAAC...AAAD...etc until it reaches the input.


did you worked with combinations before?

1. you have to make all 4 letter combinations.
2. then you get all permutatuons by next_permutation()

one and only one of the permutations is correct.

EDIT: http://www.cplusplus.com/articles/L8hv0pDG/
Last edited on
Ok wow lol thats really cool program, but i need it to not generate passwords, but to check them.
Any help?
1
2
3
4
5
6
7
8
9
string pass1 = "akl";
string pass2 = "ghr";
string input;
cin >> input;

if(input == pass1  || input == pass2) 
{
   cout << "access granted!";
}
Ummm correct me if I'm wrong, but I'm pretty sure that that program make the user guess the password? I want the computer to try every possible combination in order to try and guess the password.
i need it to not generate passwords,


I want the computer to try every possible combination in order to try and guess the password.


do you understand they are inconsistent ?
what is inconsistent?
you must generate passwords (combinations/permutations) to find correct one.

if it "guesses" like a lottery it wont be the right password.
No, it guesses the users input...
xHyperionx wrote:
...its not that easy becuase you cannot make a for loop counter with letters
Sure you can!

1
2
3
4
5
6
7
8
9
10
11
12
13
for(char firstChar = 'A'; firstChar <= 'Z'; ++firstChar)
{
    for(char secondChar = 'A'; secondChar <= 'Z'; ++secondChar)
    {
        for(char thirdChar = 'A'; thirdChar <= 'Z'; ++thirdChar)
        {
            for(char fourthChar = 'A'; fourthChar <= 'Z'; ++fourthChar)
            {
                std::cout << firstChar << secondChar << thirdChar << fourthChar << std::endl;
            }
        }
    }
}
Last edited on
wait is that actually all there is to it?
lol
and how do i make one so that its not case sensitive and it works for both A and a...?
No, it guesses the users input

do you want only one random guess?
if you try all possible permutations then that cannot be called "guess" !
................
booradley60's program finds all permutations in uppercase.

now if you want a mix of upper and lower eg AaZy, or even include digits, you need function calls in place of the increments.
Ok, like what kind of function calls?
Ok, like what kind of function calls?


function which will tell what ++firstChar means.

because, A to Z is continuous, then what will be the next increment ?
Pages: 12