I am currently working on a program, where the user of the program is required to input username and password, and the program will do the search and see if there is such user, if it exists, then proceeding to a screen with further options, or reenter the username.

The username.txt files that stores the username and password includes the following data:(first column is username, and second is password)

```
john,abc
marry,cde
admin,admin
joseph,1234

```

My code is as follows, but it doesnt work, after i input username and password, the programs automatically closes. Can you help me with it? Is there something wrong with my parsing the string into 2?

```
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<math.h>
#include<stdio.h>
using namespace std;

void printoptionsadmin(){
    cout << "Please select an option:" << endl;
    cout << "1.Sell Stock\n2.Buy stock\n3.Inquiry\n4.Logout\n5.Shutdown" << endl;
}
void printoptions(){
    cout << "Please select an option:" << endl;
    cout << "1.Sell Stock\n2.Buy stock\n3.Inquiry\n4.Logout" << endl;
}

void main()
{

    cout << "Please login." << endl;

    stop:
    string usertype;//user input
    string passtype;//user input
    string line;
    string manager = "admin";
    string managerp = "admin";
    string user;//read from file
    string pass;//read from file

    ifstream openfile("username.txt");
    cout << "Enter your username:";
    cin >> usertype;
    cout << "Enter your password:";
    cin >> passtype;

    bool found = false;
    while (found&&getline(openfile, line))
    {
        stringstream iss(line);
        getline(iss, user, ',');
        getline(iss,pass);
        if (usertype == manager && passtype == managerp)//admin login
        {
            void printoptionsadmin();
            found = true;
            break;
        }
        else if (usertype== user && passtype== pass)//regular login
            void printoptions();
        else
        {
            cout << "Invalid username or password, please start over." << endl;
            goto stop;//going back to login screen
        }
        openfile.close();
    }

}

```