-1
Visual Studio에서 작업하는 초급 프로그래머입니다. throw
를 호출throw로 인해 코드가 종료되는 대신 오류가 발생합니다.
vector<string> fileParse(vector<string> & inputStrings, string & fileName) {
ifstream x;
x.open(fileName);
cout << "attempting to open file" << endl;
if (!x.is_open()) {
cout << "Bad input file name. Input was: " << fileName << endl;
throw lab0badInput;
}
else {
string temp;
while (x >> temp) {
inputStrings.push_back(temp);
}
x.close();
}
return inputStrings;
}
내 프로그램이 올바른 값을 던지고 종료하는 대신 충돌을 일으 킵니다. 왜 누군가가 설명 할 수 있습니까?
감사합니다.
는 오류 메시지를받을 수 있나요? – Amber
어디에서 올바른 값을 던져야합니까? Plz 귀하의 프로그램에서 예외를 잡아 std :: exit() –
충돌 == 프로그램 종료 전화. –