Program terminates with no errors and no output

I am new to C++ (great fun so far) I am trying to get my code so that it will take a password from a user, validate it to the conditions for invalid, weak, medium or strong password and let the user keep only a strong password.

My code runs, takes a password from the user and then stops running.
When i say it stops running, it gives no errors at all, but wont validate the password either. When i run the code in CLion (with visual studio to compile) i get an abort error but only when the code gets to the "Enter Password"


Can someone please point out where I am going wrong/what im missing to let the password validate.


Many thanks in advance

1
2

             
Last edited on
Perhaps you can start with fixing compiler errors.
1
2
3
4
5
6
7
8
9
 In function 'char userWelcome()':
31:16: error: 'gets_s' was not declared in this scope
159:19: error: expected '(' before 'getline'
167:12: error: expected primary-expression before 'if'
167:12: error: expected ')' before 'if'
174:5: error: 'else' without a previous 'if'
174:11: error: expected primary-expression before 'if'
174:11: error: expected ')' before 'if'
150:17: warning: unused variable 'pw' [-Wunused-variable]


Your function is way too long at over 150 lines.
Break it up into several smaller functions.

Wrap long lines like this
1
2
3
4
5
string passwordError ("Password is to weak - Please try again! \\n"
    " * A Minimum of 18 Characters \\n"
    " * A Minimum of 4 UPPERCASE characters \\n"
    " * A Minimum of 3 NUMBERS \\n"
    " * A Minimum of 3 Special characters.\"<< endl;");


> regex symbols ("^(?=.*[\\character][\\w])");
This isn't a valid regex.

> if ((name[i] = ' '))
Do you really mean to overwrite characters?
L159 - opening ( is missing.

You don't put a ( before an if - Re L167-175. So:

1
2
3
4
if (a < b) 
    // statement here
else if (b < c)
    // statement here 

I realize I still have much to learn. I have a copy of my full code on pastebin (https://pastebin.com/Ke8DhApf)

After a long afternoon trying to get it to work, its stuck in a loop that i cant figure out.

The aim is that a user enters the account No (enrollment) and pin No generated, if they are correct then the user enters a desired password which is then checked against the strength criteria.

The issue i have is that the code returns a login error (incorrect Acc No and pin) when i know that the details are correct and wont let me enter a password as a result.

I have tried to change it but every time i do i end up with the error message saying that ive assigned but not referenced variables?

Pleeeaaassee Help

Many TIA
Please look up how to enable warnings on the IDE/compiler you use.

 In function 'char userWelcome()':
45:42: warning: 'firstDigit' may be used uninitialized in this function [-Wmaybe-uninitialized]

If enrollment is < 10, firstDigit is not properly initialized and this is undefined behavior.

1
2
3
4
5
6
    //check for and retrieve the length  of the first word entered from users full name
    for (int i = 0; name[i] != ' '; i++) {
        if ((name[i] = ' ')) {
            totalChar++;
        }
    }
Remove the if statement here. You're doing assignment (=) instead of checking for equality (==), but your for loop condition already covers this anyway, so it could just be
1
2
3
    for (int i = 0; name[i] != ' '; i++) {
            totalChar++;
    }

Furthermore, what happens if the user never types in a space? It will keep looping and go out of bounds. What do you want your program to do here? Perhaps
1
2
3
    for (int i = 0; i < (int)name.length() && name[i] != ' '; i++) {
            totalChar++;
    }


With that being said, tell us exactly what input you are providing, what the expected output is, and how the actual output differs from expected output.
Last edited on
The link to pastebin doesn't work - 404 error
https://pastebin.com/Ke8DhApf - thats the link just copied and pasted.

still trying to get out of this loop - its sending me loopy (LOL)

I will try making the suggest changes,

thanks all :)
The link works, it's just the board being over keen.
https://pastebin.com/Ke8DhApf
harding, you never change any of the variables that your while loop is conditioned on within the loop itself.
while (accNum == enroll && pinNo == pin) {
Once it starts looping, you have nothing that tells it to stop.
You can use an advanced IDE like Android studio to check which steps are giving the error by debugging.
Topic archived. No new replies allowed.