会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
肥斯大只仔
新随笔
管理
为什么if(int类型的负数<字符串stl的length())永远为true
int a=-1; string str="abc"; if(a<str.length()) cout<<"y"<<endl; else cout<<"x"<<endl;
测试结果:y
原因:length()返回的是unsigned类型的,int会被强制转换为unsigned,-1会被转换为4294967295
posted @
2020-10-06 22:59
肥斯大只仔
阅读(
114
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告