所以我在從我的代碼兩種類型的問題...一般形式是:與結構問題
「留下的......必須有類/結構/聯合」:
doc.id[j] = NULL;
doc.ISBN[j] = NULL;
doc.title[j] = NULL;
doc.year[j] = NULL;
和「‘doc的’使用未定義結構‘主:: m_doc’」
struct m_doc doc;
而結構m_doc文檔被包括在每個功能的頂部。
這裏是我的結構:
struct m_doc{
char id[30];
int ISBN[30];
char title[50];
char author[50];
int year[30];
};
我的拳頭功能:
void menudoc()
{ struct m_doc doc;
int c = 0, a = 0, b;
cout << "1. Them tai lieu moi" << endl;
cout << "2. Xoa tai lieu" << endl;
cout << "3. Bao cao theo nam xuat ban" << endl;
cout << "0. Tro lai menu truoc" << endl;
cout << "Ban chon:";
cin >> b;
switch (b)
{
case 1:
{
for (int i = 0;; i++)
{
if (doc.id[i] == NULL && doc.ISBN[i] == NULL && doc.title[i] == NULL && doc.author[i] == NULL && doc.year[i] == NULL)
{
i = c; break;
}
else continue;
}
cin >> doc.author[c] ;
cin >> doc.id[c] ;
cin >> doc.ISBN[c] ;
cin >> doc.title[c];
cin >> doc.year[c];
for (int i = 0;; i++){
for (int j = 1;; j++){
if (doc.id[i] == doc.id[j]){
doc.author[j] = NULL;
doc.id[j] = NULL;
doc.ISBN[j] = NULL;
doc.title[j] = NULL;
doc.year[j] = NULL;
}
if (doc.year[i]<1000 || doc.year[i]>9999){
doc.author[i] = NULL;
doc.id[i] = NULL;
doc.ISBN[i] = NULL;
doc.title[i] = NULL;
doc.year[i] = NULL;
}
}
}
break;
}
case 2:
{
int x;
char docid[50];
cout << "IDDOC: ";
cin >> docid[50];
cout << "\n";
for (int i = 0;; i++){
if (docid[50] == doc.id[i]) {
doc.author[i] = NULL;
doc.id[i] = NULL;
doc.ISBN[i] = NULL;
doc.title[i] = NULL;
doc.year[i] = NULL;
x++;
}
}
if (x == 0) cout << "IDDOC khong ton tai." << endl;
break;
}
case 3:
{
int yeardoc[50];
cin >> yeardoc[50];
for (int i = 0;; i++){
if (yeardoc[50] == doc.year[i])
write_output(i, "report.scv");
}
break;
}
case 0:
{
menubegin();
break;
}
menudoc();
}
}
我的第二個功能:
int write_output(int i, char* filename){
ios::out;
struct m_doc doc;
// open file for output
ofstream fout(filename);
char * k, *h;
k = strchr(doc.title, ',');
h = strchr(doc.author, ',');
if (k != 0 && h != 0)fout << doc.id[i] << "\n" << doc.ISBN[i] << "\n" << '"' << doc.title[i] << '"' << "\n" << '"' << doc.author[i] << '"' << "\n" << doc.year[i] << endl;
if (k != 0) fout << doc.id[i] << "\n" << doc.ISBN[i] << "\n" << '"' << doc.title[i] << '"' << "\n" << doc.author[i] << "\n" << doc.year[i] << endl;
if (h != 0)fout << doc.id[i] << "\n" << doc.ISBN[i] << "\n" << doc.title[i] << "\n" << '"' << doc.author[i] << '"' << "\n" << doc.year[i] << endl;
// write informations
if (k == 0 && h == 0)fout << doc.id[i] << "\n" << doc.ISBN[i] << "\n" << doc.title[i] << "\n" << doc.author[i] << "\n" << doc.year[i] << endl;
// close file
fout.close();
return 0;
}
任何人即時通訊問說,這是一些東西t範圍但他們都不知道這個問題,因爲一切看起來都很好...請幫助我,每一個幫助非常感謝:)
indentation?錯誤行? – AntiClimacus
當然,您可以更好地提供錯誤細節...因爲您希望人們幫助解決您收到的錯誤。沒有? – mah
您發佈第二個功能**兩次**。 – herohuyongtao