错误:“初始化程序表达式列表被视为复合表达式"; [英] error: "initializer expression list treated as compound expression"

查看:70
本文介绍了错误:“初始化程序表达式列表被视为复合表达式";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编译受密码保护的基本文件程序的开头时遇到问题,我在第11行收到上述错误(int login(username,password)).不知道这是怎么回事,所以如果有人可以对情况有所了解,那就太好了.

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 <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;
}

推荐答案

int login(username,password);
{

应该是

int login(string username,string password)
{

这篇关于错误:“初始化程序表达式列表被视为复合表达式";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆