netbeans C++调试中的信号是什么



嘿,伙计们,我正在调试我的C++应用程序(运行它不会产生错误,但也不会产生输出),它在这一点上给了我一个捕获错误的信号。

收到的信号:?(未知信号)'

试图继续调试给了我这样的信息:

无法识别或不明确的标志词\"?\?无寄存器

是什么原因造成的?错误发生在以下行:

if (input.at(i) == 'I') {

输入是一个字符串,给定用户输入(罗马数字)的值

这是以下代码的一部分(将罗马数字转换为阿拉伯数字):

//converting Roman Numerals to Arabic Numbers
int toArabic() {
    //converts input to upper case
    transform(input.begin(), input.end(), input.begin(), ::toupper); 
    int last_digit = 0;
    int current_digit = 0;
    int arabic = 0;
    //checks that input matches desired numerals
        for (int i = 0; i < sizeof(input); i++) {
           if (input.at(i) == 'I' ||
                   input.at(i) == 'V' ||
                   input.at(i) == 'X' ||
                   input.at(i) == 'L' ||
                   input.at(i) == 'C' ||
                   input.at(i) == 'D' ||
                   input.at(i) == 'M')  {
        for (int i = 0; i < sizeof(input); i++) {
            //Error occurs below
            if (input.at(i) == 'I') {
                current_digit = 1;
            }
            if (input.at(i) == 'V') {
                current_digit = 5;
            }
            if (input.at(i) == 'X') {
                current_digit = 10;
            }
            if (input.at(i) == 'L') {
                current_digit = 50;
            }
            if (input.at(i) == 'C') {
                current_digit = 100;
            }
            if (input.at(i) == 'D') {
                current_digit = 500;
            }
            if (input.at(i) == 'M') {
                current_digit = 1000;
            }
            if (last_digit < current_digit && last_digit != 0) {
                current_digit -= last_digit;
                arabic -= last_digit;
                arabic += current_digit;
                last_digit = current_digit;
                current_digit = 0;
            } else {
                last_digit = current_digit;
                arabic += current_digit;
                current_digit = 0;
            }
        }
    } else {
               break;
    }
        }
    return arabic;
}

当我实际读取无效数据时,在C++中遇到了这个问题,导致抛出异常。似乎NetBeans在调试时没有正确显示这些信息。至少在8.1版本和cygwin-gdb中,我观察到了这个问题。可能是分割错误。调试并检查NULL或无效值。

最新更新