qq_33669059 2016-03-06 04:46 采纳率: 100%
浏览 1269
已采纳

string为什么会死循环

for(string::size_type ix=str.size()-1;ix>=0;ix--) { cout<<str[ix];}

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-03-06 04:52
    关注

    string::size_type是unsigned int,所以永远>=0

     #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    string str="1234";
    for(string::size_type ix=str.size();ix>0;ix--) { cout<<str[ix-1];}
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?