smallcases
2017-07-07 09:38C++中string::type_size到底是什么,该如何理解
在学习C++过程中写了如下一串代码,调试过程中只有输入英文字母才会结束程序(跳出循环),按照我的理解只要输入的参数n不是string::size _ type就能跳出while循环了啊。
#include
using namespace std;
int main() {
const string hexdigits = "0123456789ABCDEFF";
cout << "please enter a series of number between 0 and 15\n"
<< "Separated by spaces. Hit Enter when finished: "
<< endl;
string result;
string::size_type n;
while (cin >> n)
if (n < hexdigits.size())
result += hexdigits[n];
cout << "your hex number is " << result << endl;
return 0;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
4条回答
为你推荐
- 自从Golang中的一些C删除以来,用于go的SWIG是否已过时?
- cgo
- c++
- swig
- 1个回答
- Go中类似C ++模板的行为
- templates
- c++
- 1个回答
- 与类似的内存访问相比,C ++中的链表迭代比Go中的慢
- optimization
- c++
- 1个回答
- 创建通讯录管理系统过程中产生的问题
- c++
- 1个回答
- C++如何使用EVENTLOGRECORD读取Windows系统日志解析后的详细信息
- c++
- 3个回答
换一换