私は現在、Eclipse Web サイトから直接インストールされた C/C++ で Eclipse を使用しています。何らかの理由で、私のプロジェクト ("DDSAssign2") はプロジェクトのエラーのために実行されませんが、私の 1 つのソース コード ファイルにはエラーはありません。Project Explorer のプロジェクト アイコンに表示されるだけです。この夏、Eclipse Juno と Android 開発ツールでこの問題が発生しましたが、それは常にマニフェスト ファイルにエラーがあったことを意味しているように見えました。エラーのあるファイルかもしれませんが、ソース ファイル、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 から削除できなかったので、手動で行う必要がありました。