对于一项作业,我需要允许用户输入和编辑数组中结构的数据。目前虽然我根本无法让程序调用我的编辑屏幕,更不用说编辑数组中结构的数据了。当我选择编辑程序时,程序会循环回到数据输出功能。
我的编辑画面原型是
item Edit_Screen(item one);
应该是从我的搜索功能调用
void titlesrch_bar(item s[], int limit)
{
int ctr= 0;
string title = "XXX";
string resp = "XXX";
cout << " Enter a Title to locate: "; getline(cin, title);
for( ctr = 0; ctr < limit; ctr++ )
{
if( s[ctr].BookTitle == title)
Data_Output( s[ctr].BookTitle, s[ctr].ISBN, s[ctr].Author, s[ctr].EXPenroll, s[ctr].price, s[ctr].reqNreq, s[ctr].UsedUnused);
else
{
cout << " Error: Order Not Found" << endl;
transition();
}
}
cout << " Do You Want To Edit This Order(Y/N): "; getline(cin, resp);
if(toupper(resp.at(0))=='Y')
item Edit_Screen();
}
函数被命名为
item Edit_Screen(item one)
{
string resp = "XXX";
string buffer = "XXX";
do {
cout << endl;
cout << endl;
cout << endl;
cout <<" COLLEGE BOOK ORDERING SYSTEM" << endl;
cout << endl;
cout << " Data Edit Screen" << endl;
cout << endl;
cout << endl;
cout << " Current Data" << endl;
cout << endl;
cout << " Book Title:" << one.BookTitle << endl;
cout << endl;
cout << " Book ISBN: " << one.ISBN << endl;
cout << endl;
cout << " Book Author: " << one.Author << endl;
cout << endl;
cout << " Expected Enrollment: " << one.EXPenroll << endl;
cout << endl;
cout << " Book Cost(Price): $" << one.price << endl;
cout << endl;
cout << " Is this book Required (Y/N): " << one.reqNreq << endl;
cout << endl;
cout << " Is this book Unused (Y/N): " << one.UsedUnused << endl;
cout << endl;
cout << " Select <T>itle, <I>SBN, <A>uthor, <E>xpected Enrollment, <C>ost, <R>equired, or <U>nused to edit data, or <M>enu to return to the Menu: "; getline(cin, resp);
switch(resp.at(0))
{
case 'T':
case 't':
cout << " New Title: "; getline(cin, one.BookTitle);
break;
case 'I':
case 'i':
cout << " New ISBN: "; getline(cin, one.ISBN);
break;
case 'A':
case 'a':
cout << " New Author: "; getline(cin, one.Author);
break;
case 'E':
case 'e':
cout << " New Expected Enrollment: "; getline(cin, one.EXPenroll);
while((one.EXPenroll.at(0) < '0')|| (one.EXPenroll.at(0) > '9')) // Expected enrollment error trap
{
Error_Screen(); getline(cin, one.EXPenroll);
}
break;
case 'C':
case 'c':
cout << " New Book Cost(Price): "; getline(cin, one.price);
while((one.price.at(0) < '0')|| (one.price.at(0) > '9')) // Book price error trap
{
Error_Screen(); getline(cin, one.price);
}
break;
case 'R':
case 'r':
cout << " Is this book Required(Y/N): "; getline(cin, one.reqNreq);
break;
case 'U':
case 'u':
cout << " Is this book Unused(Y/N): "; getline(cin, one.UsedUnused);
break;
default:
system("cls");
cout << " Error Please Enter T, I, A, E, C, R, or U to edit data or enter M to return to the Menu: " << endl;
system("cls");
}
} while((resp.at(0) !='M') && (resp.at(0) !='m')); // end of edit switch
return one;
}