Write a program to detect common passwords, Check file for more info

Write a program to detect common passwords.
1. Read in the given file into an array of string objects (allow for 10,000 entries).
2. Then read passwords from a user and call a function (that you write) to return whether the password is common or not. (display it in the cmd)
3. Add the password to output file and if it common or not.
Your code should have the following:
functions prototype
- (type) readPasswordIntoArray(ifstream &in, double commonPasswords[])
- bool checkPassword(string userPassword, double commonPasswords[])
Your code should
− Open close both files (input and output).
− Check if the in file opened fine or not, if not end program.

Submit the cpp file.

this is what I have so far and I am stuck


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>

#include <fstream>
#include <string>
using namespace std;

string passwords[10000];
int count = 0;

bool is_common(string password)
{
    for (int i = 0; i < count; i++) {
        if (password == passwords[i]) {
            return true;
        }
    }
    return false;
}

int main()
{
    ifstream read("passwords.txt");

    while (read >> passwords[count])
    {
        count++;
    }

    string password;
    cout << "Please enter your password\n";
    cin >> password;
    if (is_common(password))
    {
        cout << "It is common\n";
    }
    else
    {
        cout << "It is not common\n";
    }

    return 0;
}
and your question is ?
write a program to detect common passwords, this does no compile.
Last edited on
What compilation error(s) are you getting? This compiled for me on this online compiler http://ideone.com/UiTMoF but I don't have the text file you are using.
Topic archived. No new replies allowed.