Creating a password program

Hello I was wondering if anyone can help me with this code see what im doing wrong first of all I cant get the character setting right for password and when run it on visual c++ express it wont compile but works fine in c++ dev

#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>




using namespace std;





char username1;
char username2[6];
int Login;


int User()
{




cout << "Please Enter a User Id\n";
cout << "User Id must be at least 6 characters long\n";
repeat1:
cin >> username2;
if (username2[6] <= username1)
{
cout << "Please ReEnter Id Not enough characters\n";
goto repeat1;
}
else
cout << "Your User Id is "<< username2 << endl;

}





int Pass()
{

cout << "Please Enter your password\n";
cout << "Your password must be at least 7 characters long\n";


repeat3:
repeat2:

string password1;
string password2;

cin >> password1;
cout << "Please ReEnter your password\n";
cin >> password2;

if (password1 != password2)
{
cout << "You have ReEnter your password incorrectly \n";
goto repeat2;
}


if (password1[7] || password2[7])

{
cout << "Please Enter at least 7 characters\n";
goto repeat3;
}


else
cout << "You Now logged on to treasure Island\n";


}

int Welcome()

{
cout << "Welcome to Adam's Quiz Game\n";
cout << "Login Enter 1 " "Create New Account Enter 2 \n" "Press 3 to Quit\n";

cin >> Login;
if (Login == 2)

{
User();
Pass();
}

if (Login ==1)

{
cout << "bye\n";
}

}


int main()

{
Welcome ();

//ofstream dataFile;
//dataFile.open("data.txt", ios::in|ios::binary|ios::ate);
//dataFile << username1;
//dataFile.close();




system("PAUSE");
return 0;
}





How about now

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
# include <iostream>
# include <limits.h>
using namespace std;

char username1;
char username2[6];
int Login;

void User()
{
    cout << "Please Enter a User Id\n";
    cout << "User Id must be at least 6 characters long\n";

    string tmpStr;

    while(true)
    {
        cin.ignore();
        getline(cin,tmpStr);

        if(tmpStr.size()>6)break;

        cout << "Name is too short" << endl;
    }
    cout << "Your User Id is "<< tmpStr << endl << endl;
}

void Pass()
{
    cout << "Please Enter your password\n";
    cout << "Your password must be at least 7 characters long\n";

    string password1;
    string password2;

    cin >> password1;

    while(true)
    {
        cin.ignore();
        getline(cin,password2);

        if(!password1.compare(password2))break;

        cout << "You have ReEnter your password incorrectly" << endl;
    }
    cout << "You Now logged on to treasure Island\n";
}

void Welcome()
{
    cout << "Welcome to Adam's Quiz Game" << endl;
    cout << "Login Enter 1 " << endl;
    cout << "Create New Account Enter 2" << endl;
    cout << "Press 3 to Quit" << endl << endl;

    cin >> Login;

    if(Login == 2)
    {
        User();
        Pass();
    }

    if(Login == 1)
        cout << "Enter" << endl;
}

int main()
{
    Welcome ();

    //ofstream dataFile;
    //dataFile.open("data.txt", ios::in|ios::binary|ios::ate);
    //dataFile << username1;
    //dataFile.close();

    cin.ignore(INT_MAX,'\n');

    return 0;
}
Topic archived. No new replies allowed.