【发布时间】:2016-12-15 21:37:58
【问题描述】:
#include <iostream>
using namespace std;
struct dateofbirth{
char day[2];
char month[2];
char year[4];
};
struct address{
char city[20];
char address[20];
};
struct Student{
char Fname[20];
char Lname[20];
char ID[10];
char email[20];
char gpa[5];
struct dateofbirth;
struct address;
};
int check (student x[],int n,char key[],char key2[]){
for(int i=0;i<n;i++)
{
if(strcmp(x[i].ID,key[])==0 && strcmp(x[i].Pass,key2[])==0)
return i;
}
return -1;
};
int main() {
char ID[10];
char Pass[10];
char x;
int res;
cout << "If you are a student please press ' S ' "<< endl
<< "If you are an admain pleass press ' A ' "<< endl;
cin>> x;
if (x == 's' || x == 'S') {
cout<<"Enter your ID ";
cin>>ID;
cout<<"Enter your password ";
cin>>Pass;
res=check(list,n,ID,Pass);
}
else {
cout<<"error";
}
}
return 0;
这个错误是什么意思???
||=== 构建:在 try 中发布(编译器:GNU GCC 编译器)===|
E:\try\main.cpp|26|错误:“学生”未在此范围内声明|
E:\try\main.cpp|26|错误:'int'之前的预期主表达式|
E:\try\main.cpp|26|错误:'char' 之前的预期主表达式|
E:\try\main.cpp|26|错误:'char' 之前的预期主表达式|
E:\try\main.cpp|26|错误:表达式列表在初始化程序中被视为复合表达式 [-fpermissive]|
E:\try\main.cpp|26|错误:预期的 ',' 或 ';'在“{”标记之前|
||=== 构建失败:6 个错误,0 个警告(0 分钟,0 秒)===|
【问题讨论】:
-
编译器不知道以下表达式“int check (student x[],int n,char key[],char key2[])”中的“student”是什么。在这之前的几行声明了一个名为 Student 的结构(提示)。 BW:我想这与 Arduino 无关,所以你可能上错论坛了。
-
这个问题与计算机科学完全无关。请edit您的问题 a) 包含一个清楚地解释您遇到的问题或您要问的问题的标题; b) 包含您正在编码的语言的标签; c) 清楚地解释您在转储代码时遇到的问题,并询问有关该代码的特定问题。如果您需要帮助,请阅读How to Ask,然后了解如何创建minimal reproducible example。
-
投下愚蠢的标题,和compiler-construction也没有任何关系。
标签: c++ compiler-errors