Error: "initializer expression list processed as a compound expression"

I had a problem compiling the basics of a basic password-protected file program, I get the above error on line 11 (int login (username, password)). Not sure what is going on here, so it would be nice if someone could shed light on the situation.

#include <iostream>
#include <conio.h>
#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;
}
+3
source share
4 answers
int login(username,password);
{

it should be

int login(string username,string password)
{
+6
source

You may not be able to commit the function declaration.

int login(username,password);

Should be changed to

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

, , .

+3

You must specify the username and password data types.

+1
source

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

For instance:

int foo(int parameter)
{
    return parameter + 1;
}
0
source

Source: https://habr.com/ru/post/1776991/


All Articles