C++ 十六进制转换输出错误

书上的十六进制转换的例子,输出时出现错误

 #include <iostream>
using namespace std;

int main() {
    const string hexdigits = "0123456789ABCDEF";
    cout << "Enter a series of numbers between 0 - 15" <<
            "separated by space . Hit Enter when finished : " <<endl;
    string result;
    string::size_type n;
    while (cin >> n)
        if (n < hexdigits.size())
            result += hexdigits[n];
    cout << result << endl;
}

错误信息

 GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
[New Thread 200.0x1030]
Quit (expect signal SIGINT when the program is resumed)

你确定你没有打错代码,参考下面这个:

 #include <iostream>  
#include<string>  

using namespace std;


int  main()
{
    const string hexdigits = "0123456789ABCDEF";//可能的十六进制数值  
    cout << "请输入0-15之间的数值:";

    char result;    //用于保存十六进制的字符  
    string::size_type n;    //用于保存从输入流读取的数据  

    while (cin >> n)
    if (n<hexdigits.size())   //忽略无效的输入  
    {
        result = hexdigits[n];    //得到对应的16进制的数  
        cout << n << "对应的十六进制数是:" << result << "  " << endl;
    }
    else cout << n << "无效的输入" << endl;

    return 0;
}

这并不是错误信息啊,你这个程序也不是输入Enter就结束 啊

No symbol table is loaded. Use the "file" command.应该是你没有生成调试信息吧。
首先加-g选项生成带有调试信息(符号表等)的二进制文件
gcc -g -o main.exe main.c
然后再用gdb调试
gdb main.exe