在函数参数中获取 ) 预期的错误
Getting ) expected errror in function argument
我正在尝试制作学生成绩单(大约 10 名学生(
我收到 1 个错误,即"错误测试。CPP 18: ( 预期" 请查看代码并帮助我。
当我删除参数时,我得到 25 个错误。
我没有被教导过关于课程或工会的知识。
我只知道直到结构。所以请不要给出结构以外的解决方案。
#include<iostream.h >
#include<conio.h >
#include<stdio.h >
struct subject
{
float phy, chem, maths, CS, eng;
}ss;
struct student
{
int rno;
char name[40];
char Mname[40];
char Fname[40];
subject marks;
};
void grade(student U[].marks) // THIS BLOCK IS GIVING ERROR
{
char Gphy, Gch, Gmath, GCS, Ge;
// For Physics
if (U.marks.phy >= 91 && U.marks.phy <= 100)
Gphy = "A1";
else if (U.marks.phy >= 81 && U.marks.phy <= 90)
Gphy = "A2";
else if (U.marks.phy >= 71 && U.marks.phy <= 80)
Gphy = "B1";
else if (U.marks.phy >= 61 && U.marks.phy <= 70)
Gphy = "B2";
else if (U.marks.phy >= 51 && U.marks.phy <= 60)
Gphy = "C1";
else if (U.marks.phy >= 41 && U.marks.phy <= 50)
Gphy = "C2";
else if (U.marks.phy >= 33 && U.marks.phy < 490)
Gphy = "D";
else if (U.marks.phy >= 21 && U.marks.phy <= 32)
Gphy = "E1";
else
Gphy = "E2";
// For Chemistry
if (U.marks.chem >= 91 && U.marks.chem <= 100)
Gchem = "A1";
else if (U.marks.chem >= 81 && U.marks.chem <= 90)
Gchem = "A2";
else if (U.marks.chem >= 71 && U.marks.chem <= 80)
Gchem = "B1";
else if (U.marks.chem >= 61 && U.marks.chem <= 70)
Gchem = "B2";
else if (U.marks.chem >= 51 && U.marks.chem <= 60)
Gchem = "C1";
else if (U.marks.chem >= 41 && U.marks.chem <= 50)
Gchem = "C2";
else if (U.marks.chem >= 33 && U.marks.chem < 490)
Gchem = "D";
else if (U.marks.chem >= 21 && U.marks.chem <= 32)
Gchem = "E1";
else
Gchem = "E2";
// For Maths
if (U.marks.math >= 91 && U.marks.math <= 100)
Gmath = "A1";
else if (U.marks.math >= 81 && U.marks.math <= 90)
Gmath = "A2";
else if (U.marks.math >= 71 && U.marks.math <= 80)
Gmath = "B1";
else if (U.marks.math >= 61 && U.marks.math <= 70)
Gmath = "B2";
else if (U.marks.math >= 51 && U.marks.math <= 60)
Gmath = "C1";
else if (U.marks.math >= 41 && U.marks.math <= 50)
Gmath = "C2";
else if (U.marks.math >= 33 && U.marks.math < 490)
Gmath = "D";
else if (U.marks.math >= 21 && U.marks.math <= 32)
Gmath = "E1";
else
Gmath = "E2";
// For Computers
if (U.marks.CS >= 91 && U.marks.CS <= 100)
GCS = "A1";
else if (U.marks.CS >= 81 && U.marks.CS <= 90)
GCS = "A2";
else if (U.marks.CS >= 71 && U.marks.CS <= 80)
GCS = "B1";
else if (U.marks.CS >= 61 && U.marks.CS <= 70)
GCS = "B2";
else if (U.marks.CS >= 51 && U.marks.CS <= 60)
GCS = "C1";
else if (U.marks.CS >= 41 && U.marks.CS <= 50)
GCS = "C2";
else if (U.marks.CS >= 33 && U.marks.CS < 490)
GCS = "D";
else if (U.marks.CS >= 21 && U.marks.CS <= 32)
GCS = "E1";
else
GCS = "E2";
// For English
if (U.marks.eng >= 91 && U.marks.eng <= 100)
Ge = "A1";
else if (U.marks.eng >= 81 && U.marks.eng <= 90)
Ge = "A2";
else if (U.marks.eng >= 71 && U.marks.eng <= 80)
Ge = "B1";
else if (U.marks.eng >= 61 && U.marks.eng <= 70)
Ge = "B2";
else if (U.marks.eng >= 51 && U.marks.eng <= 60)
Ge = "C1";
else if (U.marks.eng >= 41 && U.marks.eng <= 50)
Ge = "C2";
else if (U.marks.eng >= 33 && U.marks.eng < 490)
Ge = "D";
else if (U.marks.eng >= 21 && U.marks.eng <= 32)
Ge = "E1";
else
Ge = "E2";
}
void input(student A[45])
{
clrscr();
int n;
cout << "Enter number of Students present (max. 45 ) : ";
cin >> n;
char t;
cout << "Student List (enter 0 to terminate)n ";
for (int i = 0; i < n; i++) {
gotoxy(20, 5);
cout << "====Student Number" << i + 1 << "====n";
cout << "Enter Student's name : ";
gets(A[i].name);
cout << "Enter Mother's name : ";
gets(A[i].Mname);
cout << "Enter Father's name : ";
gets(A[i].Fname);
cout << "Enter roll no. of Student :";
cin >> A[i].rno;
cout << "Get Ready to enter marks of each subject....n";
clrscr();
gotoxy(20, 5);
cout << "==== Marks section ====n";
gotoxy(20, 7);
cout << "Physics : ";
gotoxy(20, 9);
cout << "Chemistry : ";
gotoxy(20, 11);
cout << "Maths : ";
gotoxy(20, 13);
cout << "Computers : ";
gotoxy(20, 15);
cout << "English : ";
gotoxy(31, 7);
cin >> A[i].marks.phy;
gotoxy(31, 9);
cin >> A[i].marks.chem;
gotoxy(31, 11);
cin >> A[i].marks.maths;
gotoxy(31, 13);
cin >> A[i].marks.CS;
gotoxy(31, 15);
cin >> A[i].marks.eng;
cout << endl;
cout << "Do you want to enter more? (y/n) : ";
cin >> t;
if (t == 'y' || t == 'Y') {
clrscr();
continue;
} else if (t == 'n' || t == 'N')
break;
else {
cout << "Invalid choice, continuing..n";
continue;
}
}
}
void marks(student I[10])
{
cout << "Student Details";
for (int q = 0; q <= 75; q++)
cout << "=";
cout << "R.notNametP C M E CS %age Graden";
for (q = 0; q <= 75; q++)
cout << "=";
cout << endl;
for (int i = 0; i < 10; i++) {
gotoxy(20, 5);
cout << "====Student " << i << "====n";
cout << "Physics : " << I[i].marks.phy << endl;
cout << "Chemistry : " << I[i].marks.chem << endl;
cout << "Maths : " << I[i].marks.maths << endl;
cout << "Computers : " << I[i].marks.CS << endl;
cout << "English : " << I[i].marks.eng << endl;
}
getch();
}
void main()
{
int ch = 0;
while (ch != 4) {
clrscr();
student S[10];
gotoxy(20, 5);
cout << "Student Report n";
gotoxy(20, 7);
cout << "1. Enter detailsn";
gotoxy(20, 8);
cout << "2. Display report of a student via roll no.n";
gotoxy(20, 9);
cout << "3. Display report of all studentsn";
gotoxy(20, 10);
cout << "4. Exitn";
gotoxy(20, 11);
cout << "Enter your choice [1-4] : ";
cin >> ch;
switch (ch) {
case 1:
input(S);
break;
case 4:
cout << "Exiting...........";
break;
default:
cout << "Invalid choice.";
break;
}
getch();
}
}
void grade(student U[].marks) // THIS BLOCK IS GIVING ERROR
这不是一个块,它是一个函数声明,它给出一个错误,因为它不是有效的C++。你需要声明一个参数及其类型,这不是你这样做的方式。你如何做到这一点完全取决于你打算将论点定为哪种类型,这甚至不太清楚。
好的,
我修复了错误
无效成绩(学生 U[].分数(替换为无效成绩(浮动 G(
相关文章:
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- xmake总是报告:错误:无法获取cxx的程序,为什么
- 使用 strcat 获取缓冲区溢出错误
- 无法使用 SWIG 在 Python 中实例化C++类(获取属性错误)
- 在 alglib::real_1d_array 中获取元素总和的奇怪错误
- 无法使函数公开。获取:"LNK2005"错误。如何调试链接器错误
- 为什么我在空指针错误(链表)中获取成员访问权限
- C++ 随机数生成器:尝试将结果作为向量获取,但通过制作 void 函数来执行此操作而出现错误
- 获取毫秒延迟的错误值
- 获取 clang++:错误:在编译文件系统库的代码时
- 在 Eclipse: "error: no match for 'operator='" 中获取错误消息
- 如何在常量计算表达式中获取编译时错误?
- 获取"rw_ssid"中成员"长度"的错误请求,该成员属于非类类型"char*"
- Assimp 库错误:获取打包成员的地址
- 错误:获取临时地址
- [错误]获取C++中临时数组的地址
- 错误:获取临时[-fpermissive] -npc_multivendor的地址
- C++:为“char [4]”数组错误获取太多初始值设定项
- 字符串数据成员的指针错误 - 获取访问冲突
- 调用派生类时 - 错误:获取临时 [-fallowive] 的地址