注册 登录
编程论坛 C++教室

求大神看看出了神马问题,再Xcode写的

z21530081 发布于 2015-08-27 14:29, 576 次点击
在xcode里运行时抓不住错误,在vc里可以正常显示


#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
   
    int ReturnCode = 0;
   
    cin.exceptions(cin.failbit);
   
    try {
        float Dividend=0;
        cout << "Dividend: ";
        cin >> Dividend;
        
        float  Divisor =1;
        cout << "Divisor: ";
        cin >> Divisor;
        
        float Result = (Dividend/Divisor);
        cout << Result << endl;
    }
    catch (...)
    {
        cout <<
        "Input error, not a number?"
        << endl;
        
        cin.clear();
        
        char Badinput[5];
        cin >> Badinput;
        
        ReturnCode=1;
    }
   
   
    char StopCharacter;
    cout << endl << "Press a key and \"Enter\":" ;
    cin >> StopCharacter;
   
    return ReturnCode;
}



输入输出
Dividend: a
Divisor: 0

Press a key and "Enter":
3 回复
#2
wp2319572015-08-27 16:44
又是无头无尾
#3
z215300812015-08-27 22:09
回复 2楼 wp231957
神马无头无尾
#4
z215300812015-08-30 15:44
解决了
1