이 코드의 목적은 기본 라이브러리 체크인 체크 아웃 시스템으로 ISBN 번호 인 바코드를 입력 한 다음 프로그램이 내 .txt 데이터베이스를보고 검색합니다 책 이름 그런 다음 책을 체크 아웃하고 학생 ID 번호를 묻고 ISBN, out/in, id 번호 및 현재 시간을 FILE로 출력 할 것인지 묻습니다. 이 프로그램은 처음에는 잘 작동하지만 바코드를 입력 한 후에 다른 책을 체크 아웃하려고하면 작동을 멈 춥니 다. 그냥 멈추지 않으면 입력 캔트 이동을하지 않습니다.올바르게 루핑되지 않음
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
char variable = 1;
ifstream infile;
ofstream outfile;
infile.open("Library_Database.txt");
outfile.open("Library_Checkout.txt", ios::app);
do {
char variable;
cout << "SETSUCON MANGA LIBRARY DATABASE\n\n" << setw(45) << "For Check-Out please enter: O or o\n" << setw(45) << "For Check-In please enter: I or i\n" << setw(45) << "For Assistance please enter: H or h\n" << setw(45) << "To close this program please enter: Q or q\n" << setw(50) << "Enter an option: ";
cin >> variable;
cout << "\n";
if (variable == 'O' || variable == 'o'){
double search;
double ISBN = 0;
string bookName;
cout << "Please Scan Barcode: ";
cin >> search; //runs fine one time then gets stuck here after I input the ISBN number the second time
while (ISBN != search){
infile >> ISBN >> bookName;
}
cout << "You would like to check out: " << bookName << "?" << endl;
string idNumber;
char yesOrNo;
cout << "Yes or No (Y or N): ";
cin >> yesOrNo;
if (yesOrNo == 'Y' || yesOrNo == 'y'){
cout << "Please input Student ID number or Badge ID Number: ";
cin >> idNumber;
cout << endl;
time_t now = time(0);
char* dt = ctime(&now);
outfile.setf(ios::fixed);
outfile.precision(0);
outfile << search << std::resetiosflags(std::ios::showbase) << setw(12) << idNumber << setw(4) << "out" << setw(30) << dt << endl;
}
else{
cout << endl << "\n";
continue;
}
}
else if (variable == 'I' || variable == 'i'){
double search;
double ISBN = 0;
string bookName;
cout << "Please Scan Barcode: ";
cin >> search; //runs fine one time then gets stuck here after I input the ISBN number the second time
while (ISBN != search){
infile >> ISBN >> bookName;
}
cout << "You would like to check in: " << bookName << "?" << endl;
string idNumber;
char yesOrNo;
cout << "Yes or No (Y or N): ";
cin >> yesOrNo;
if (yesOrNo == 'Y' || yesOrNo == 'y'){
cout << "Please input Student ID number or Badge ID Number: ";
cin >> idNumber;
cout << endl;
time_t now = time(0);
char* dt = ctime(&now);
outfile.setf(ios::fixed);
outfile.precision(0);
outfile << search << std::resetiosflags(std::ios::showbase) << setw(12) << idNumber << setw(4) << "in" << setw(30) << dt << endl;
}
else{
cout << endl << "\n";
continue;
}
}
else if (variable == 'H' || variable == 'h'){
cout << "This program was written Shea Transue.\n" << "For Assistance Please Contact Shea Transue at 484-264-5863\n\n";
}
else if (variable == 'Q' || variable == 'q') {
cout << "Thank you for using the SETSUCON LIBRARY DATABASE.\n" << "For assistance please Call or Text Shea Transue at 484-264-5864\n\n";
break;
}
else {
cout << variable << " is not a valid option. Try again\n\n";
}
} while (variable != 'Q' || variable != 'q');
infile.close();
outfile.close();
return 0;
}
디버거에서 실행하고 줄 단위로 코드를 단계별로 실행 했습니까? 그렇지 않은 경우, 지금 어떻게하는지 배울 수있는 좋은 시간입니다. – Cornstalks
전화 번호 목록이 일치하지 않습니다. – Potatoswatter
Visual Studio에서 프로그램을 실행하고 디버거를 사용하는 방법이나 줄 단위로 이동하는 방법을 모르겠습니다. 나는 그것이 내가 가지고 있다고 말하는 오류를 바로 잡는다. 좋은 튜토리얼을 제안 해 주시겠습니까? 또한 나는 내 전화 번호 롤 오타를 만들었습니다 감사합니다. – Shea