大量的编译器错误
An awful lot of compiler errors
好吧,我正在用C++Bloodshed为我的大学作业做一个程序,但我一直会遇到很多错误,比如"在")"token"、"在"else"之前的语法错误和"输入末尾的语法错误"。这是代码,如果你能帮我,我将非常感激。
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;
int points=0; //this is a global variable. it's made of variables and planets.
string studentID;
string units[10]; //global array of ten game matches in total.
char grades[10]; //these are the global medals that are awarded.
void intro();
void load_units(); //this, the above and the below are all prototypes; defines what the function is.
void award_grades();
void award_points();
void set_units();
int main(int argc, char* argv[])
{
intro();
load_units();
award_grades();
award_points();
cout<<"You have achieved..."<<points<<endl;
set_units();
system("PAUSED!!!!");
return EXIT_SUCCESS;
}
void intro()
{
cout<<"Welcome to the Grading System for BTEC!"<<endl;
cout<<"This app will determine your grades, with either Pass, Merit, or Distinction." <<endl;
cout<<"Please enter your name to continue."<<endl;
cin>>studentID;
}
void load_points()
{
units[0]="NOCN";
units[1]="Animation";
units[2]="Game Designing";
units[3]="OSS";
units[4]="HCI";
units[5]="Digital Art";
units[6]="SAD";
units[7]="Project Planning";
units[8]="Procedural Programming";
units[9]="Database Design";
}
void award_grades()
{
int index; //This is a local variable. It more or less allows for a global variable's value to be retained.
for (index=0; index<10; index=index+1)
{
{
cout<<"What grade did you get for the"<<units[index]<<"unit?"<<endl;
cin>>grades[index];
}
void award_points();
for (index=0, index<10, index=index+1)
switch (grades[index]);
{
case'distinction':
points=points +3; //Code for the event points. The following are also event codes...
break;
case'merit':
points=points +2;
break;
case'pass':
points=points +1;
break;
case'd':
points=points +3;
break;
case'm':
points=points +2;
break;
case'p':
points=points +1;
break;
}
}
}
void set_units()
{
if(points>13)
{// if the points are more than 13 then...
cout<<studentID + "Well done! You have a distinction!"<<endl;
}
{
else if(points<8);//otherwise, if points are more than 8 but below more than 13, then...
cout<<studentID+"Congratulations, you have a merit!"<<endl;
}
{
else if(points<3); //If the points are more than 3 but not more than 8 then...
cout<<studentID+"You have a pass! Try to keep it up and get a higher grade."<<endl;
}
{
else; //if none of these conditions are met, then...
{
cout<<studentID + "Your studentID is not enlisted. Either enrol, or re-enter your name correctly. Remember, it's case-sensitive."<<endl;
}
大概,错误消息指向这行
for (index=0, index<10, index=index+1)
你写了,
,意思是;
一旦你解决了这个问题,第一条错误消息可能会将你指向或接近
switch (grades[index]);
你有一个流氓;
然后它会指向set_units
中的加扰if...else
格式,它看起来应该有点像
if (...) {
...
} else if (...) {
...
} else {
...
}
首先,逗号应该是分号:
for (index=0; index<10; index=index+1)
第二,你的switch
:后面有一个分号
switch (grades[index])
第三,不能将switch
用于string
,更不用说多字符char
了。它会把它转换成一个大屁股数字,这可能不是你想要的。相反,您需要将其重构为if语句。
Linker错误正在发生,因为您已经定义了函数load_units
和award_points
:-的原型。)如果您定义这些函数的主体,您将不会得到错误。顺便说一句,这看起来就像我在电脑游戏开发第一年的任务:-)祝你好运
相关文章:
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++,我收到一个无法理解的编译器错误
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 重载方法的方式会在使用临时调用时生成编译器错误
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- 有没有办法让编译器在我放置字符串而不是 nlohmann::json 对象时抛出错误?
- 致命错误 C1001 :vs2017 15.8.4 的内部错误(编译器文件"msc1.cpp",第
- C++2440错误-编译器认为字符串是常量字符
- Clang 错误 – 编译器错误或缺少一些细节?
- 视觉C++ 2017 错误?编译器优化表达式
- 配置:错误:C++编译器无法创建可执行文件
- PHP PDO_ODBC配置:错误:C 编译器无法创建可执行文件
- 致命错误 C1001:内部编译器错误(编译器文件"MSC1.cpp",第 1794 行)
- 错误:编译器限制达到简单hello world程序的堆限制
- c++链接错误:编译器找不到函数的定义
- 生成 CImg 时出现致命错误(编译器限制)
- 抛出对齐类型时出现 Clang 运行时错误.编译器错误