【发布时间】:2016-09-24 00:35:14
【问题描述】:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main(){
stringstream ss;
ss << 32;
string str = ss.str();
cout << str << endl
<< str[0] << endl
<< str[1] <<endl
<< str[0]%10;
return 0;
}
输出是:
32
3
2
1
相反,最后一行应该是 3 as 3%10=3。
【问题讨论】:
-
str[0] 为 51,51%10 为 1
-
打印
cout << +str[0];和cout << (str[0] - '0')会得到什么?
标签: c++ string io stringstream mod