5

I'm having an issue compiling the beginnings of a basic password protected file program, I'm getting the above error on line 11, (int login(username,password)). Not sure what's going on here, so it'd be nice if someone could shed some light on the situation.

#include <conio.h>
#include <iostream>
#include <string>

using namespace std;

int    i, passcount, asterisks;
char   replace, value, newchar;
string username, password, storedUsername, storedPassword;

int login(username, password);
{
    if (username == storedUsername) {
        if (password == storedPassword)
            cout << "Win!";
        else
            cout << "Username correct, password incorrect."
    } else
        cout << "Lose. Wrong username and password.";
}

int main() {
    cout << "Username: ";
    cin >> username;
    cout << "Password: ";
    do {
        newchar = getch();
        if (newchar == 13)
            break;
        for (passcount > 0; asterisks == passcount; asterisks++)
            cout << "*";
        password = password + newchar;
        passcount++;
    } while (passcount != 10);
    ifstream grabpass("passwords.txt") grabpass >> storedpass;
    grabpass.close();
    login(username, password);

    return 0;
}
sehe
  • 374,641
  • 47
  • 450
  • 633
Captain Lightning
  • 10,493
  • 4
  • 19
  • 17

4 Answers4

9
int login(username,password);
{

should be

int login(string username,string password)
{
AndersK
  • 35,813
  • 6
  • 60
  • 86
4

You may wan't to fix function declaration

int login(username,password);

Should be changed to

int login(const string& username,const string& password);

Also as a style note, you may not want to declare global variable, you can limit scope of most of your variables to local scope in main.

1

You have to specify the data types of username and password.

Pavel
  • 33
  • 6
0

When declaring a user-defined function with parameters, you must declare the parameter types as well.

For example:

int foo(int parameter)
{
    return parameter + 1;
}
Maxpm
  • 24,113
  • 33
  • 111
  • 170