sign up, login program

Hello, I am trying to figure out why my code is not working. It is a simple login and signup program. My problem is that the "while" function on Line: 66 does not work and gives me an error when I run it. There are 2 .txt files which store the usernames and passwords. The program is compiling successfully but the crashes when I try to log in.

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <iostream>
#include <string>
#include <windows.h>
#include <fstream>
#include <conio.h>
#include <stdio.h>

#include "clrscr.h"// allows me to use clrscr();Made it myself, it just clears the screen and does system("pause")

using namespace std;

int main()
{
    int i = 0;

    string user, chuser[99];
    string pass, chpass[99];
    string llos;
    string los;
    string suser;
    string spass;

    fstream unm("name.txt");
    fstream pwd("pass.txt");

    SetConsoleTitle("ICG SECURITY");
    cout << "Welcome to ICG Security System." << endl;
    Sleep(1000);
a:
    cout << "LOGIN or SIGNUP:" << endl;
    cin >> los;
    if (los == "signup" || los == "SIGNUP" || los == "Signup")
    {

        cout << "Please type in your new username:" << endl;
        cin >> suser;
        unm << suser << endl;
        cout << "Please type in your new password:" << endl;
        cin >> spass;
        pwd << spass << endl;
        cout << "You have successfully Signed Up to ICG.\nClose the program and login!\n" << endl;
		unm.close();
		pwd.close();
        Sleep(3000);
        clrscr();
        goto a;
    }
    else
    {
        goto b;
    }

	if (!(unm)){
		perror("File info");
	}
	if (!(pwd)){
		perror("File info");
	}

    cin >> llos;
    if (llos == "login" || llos == "LOGIN" || llos == "Login")
    {
b:
        cout << "Please type in your username:" << endl;
        cin >> user;
        while (unm)// around here is the error I get
        {
	unm >> chuser[i];

	if (user == chuser[i])
            {
                cout << "Please type in your password:" << endl;
                cin >> pass;
		i = 0;
                while (pwd)
                {
	         pwd >> chuser[i];
                    
                    if (pass == chpass[i])
                    {
                        cout << "LOGIN COMPLETE!" << endl;
                        Sleep(2000);
                        clrscr();
                        goto a;
                    }
		i++;
                }
            }
	i++;
        }
    }
    else
    {
        cout << "Invalid Details" << endl;
        Sleep(2000);
        clrscr();
        goto a;
    }
	clrscr();
    return 0;
}
Please copy and paste the exact error message.

goto is considered bad practice, especially the way you're using it. Try to eliminate it from your program.
n Line: 66 does not work and gives me an error when I run it.
The program is compiling successfully but the crashes when I try to log in.


So which is it? Does it crash or does it give an error while compiling?
Topic archived. No new replies allowed.