我目前正在使用带有C / C ++的Eclipse,直接从Eclipse网站安装。由于某些原因,我的项目(“DDSAssign2”)将因为项目中的错误而无法运行,尽管我的一个源代码文件没有任何错误。它只显示在Project Explorer中的项目图标上。今年夏天我偶尔会遇到Eclipse Juno和Android开发工具这个问题,但这似乎总是意味着Manifest文件中有一个错误,我知道C ++中不应该存在这个错误,尽管我认为这可能意味着可能是某些文件有错误,但我只有源文件,MinGW包含,以及可执行二进制文件和可执行文件进行调试。
这是代码。代码本身的编辑器没有错误,而且它运行得更早。红色错误图标仅显示在整个项目的Project Explorer中。
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
struct stud
{
int id;
double gpa;
char className;
struct stud *next;
};
struct stud *add(struct stud *top);
void show(struct stud *top);
int main()
{
struct stud *top = NULL;
srand(time(NULL));
int x = 0;
while (x == 0)
{
top = add(top);
cout << "Press [0] to continue, any other integer to quit.";
cin >> x;
}
show(top);
return 0;
}
struct stud *add(struct stud *top)
{
struct stud *dum;
dum = (struct stud *)malloc(sizeof(struct stud));
cout << "What is the student's ID?" << endl;
cin >> dum->id;
cout << "What is the their GPA?" << endl;
cin >> dum->gpa;
cout << "What is their class?" << endl;
cin >> dum->className;
if (top == NULL)
{
top = dum;
}
else
{
while (top != NULL)
{
if (top->next == NULL)
top->next = dum;
if (dum->id < top->id)
{
struct stud *dum2 = top->next;
if (dum->id < dum2->id)
{
dum->next = top->next;
top->next = dum;
}
}
top = top->next;
}
}
return top;
}
void show(struct stud *top)
{
if (top == NULL)
{
cout << "Stack is empty.";
}
while (top != NULL)
{
cout << "ID: " << top->id << endl;
cout << "GPA: " << top->gpa << endl;
cout << "Class: " << top->className << endl;
top = top->next;
}
}
我想知道的另一件事是,这是因为项目的名称。我现在已经重新制作了这个“DDSAssign2”项目几次,试图摆脱这个问题,上次我无法从Eclipse中删除工作区中的内容,所以我只需要手动完成。