D*1
2 楼
潜水同学还不少,除来喘口气,吃个饱子吧。40个
e*r
3 楼
int main()
{
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
while (!iss.eof())
{
iss >> temp;
cout << temp << endl;
}
}
So why an extra white space in s matters?
{
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
while (!iss.eof())
{
iss >> temp;
cout << temp << endl;
}
}
So why an extra white space in s matters?
g*o
5 楼
吃!
沙发要求双簧!
沙发要求双簧!
z*y
6 楼
First, when eof bit is set
iss >> temp;
cout << temp << endl;
will always return the last element read, which in this case is C. This may
or may not be a bug depending how you look at it.
When it comes to the last white space, it returns immediately with element C.
But the eof bit is not set yet. Then it calls "iss >> temp" again. Nothing
is read, the last element C is returned (second time), the eof bit is set,
and the while loop quits.
If the last character is C, it returns C and at the same time sets the eof
bit. So the while quits and no extra C is printed.
iss >> temp;
cout << temp << endl;
will always return the last element read, which in this case is C. This may
or may not be a bug depending how you look at it.
When it comes to the last white space, it returns immediately with element C.
But the eof bit is not set yet. Then it calls "iss >> temp" again. Nothing
is read, the last element C is returned (second time), the eof bit is set,
and the while loop quits.
If the last character is C, it returns C and at the same time sets the eof
bit. So the while quits and no extra C is printed.
g*o
8 楼
再吃一个
c*p
11 楼
吃
正在煮五香毛豆
正在煮五香毛豆
m*5
12 楼
why you use iss.eof()?
The common way to do this is directly check after iss>>temp, because their
can be fail, bad, whitespace, or eof. If either fail/bad signal is True, the
temp is not valid.
###
void test(){
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
int _i = 0;
while (!iss.eof())
{
cout << _i << " iss stat[good,bad,fail,eof]: [" << iss.good() << iss
.bad() < iss >> temp;
cout << _i<< " iss stat after: [" << iss.good() << iss.bad() < fail() < _i++;
}
}
###>>>
0 iss stat[good,bad,fail,eof]: [1000] 0 iss stat after: [1000] temp: A
1 iss stat[good,bad,fail,eof]: [1000] 1 iss stat after: [1000] temp: B
2 iss stat[good,bad,fail,eof]: [1000] 2 iss stat after: [1000] temp: C
3 iss stat[good,bad,fail,eof]: [1000] 3 iss stat after: [0011] temp: C
###
We can see the last reading is not valid since the state is fail.
if the s does not have the whitespace:
###>>>
0 iss stat[good,bad,fail,eof]: [1000] 0 iss stat after: [1000] temp: A
1 iss stat[good,bad,fail,eof]: [1000] 1 iss stat after: [1000] temp: B
2 iss stat[good,bad,fail,eof]: [1000] 2 iss stat after: [0001] temp: C
###
We can see the last reading is not fail/bad just eof meaning the last
reading is OK but no further reading is needed.
Here is the common way:
void test2(){
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
int _i = 0;
while (iss>>temp)
{
cout << _i<< " iss stat after: [" << iss.good() << iss.bad() < fail() < _i++;
}
}
test2:
0 iss stat after: [1000] temp: A
1 iss stat after: [1000] temp: B
2 iss stat after: [1000] temp: C
【在 e*****r 的大作中提到】
: int main()
: {
: string s = "A B C "; // output is A B C C
: // If string s = "A B C", then the output would be A B C
: istringstream iss(s);
: string temp;
: while (!iss.eof())
: {
: iss >> temp;
: cout << temp << endl;
The common way to do this is directly check after iss>>temp, because their
can be fail, bad, whitespace, or eof. If either fail/bad signal is True, the
temp is not valid.
###
void test(){
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
int _i = 0;
while (!iss.eof())
{
cout << _i << " iss stat[good,bad,fail,eof]: [" << iss.good() << iss
.bad() <
cout << _i<< " iss stat after: [" << iss.good() << iss.bad() <
}
}
###>>>
0 iss stat[good,bad,fail,eof]: [1000] 0 iss stat after: [1000] temp: A
1 iss stat[good,bad,fail,eof]: [1000] 1 iss stat after: [1000] temp: B
2 iss stat[good,bad,fail,eof]: [1000] 2 iss stat after: [1000] temp: C
3 iss stat[good,bad,fail,eof]: [1000] 3 iss stat after: [0011] temp: C
###
We can see the last reading is not valid since the state is fail.
if the s does not have the whitespace:
###>>>
0 iss stat[good,bad,fail,eof]: [1000] 0 iss stat after: [1000] temp: A
1 iss stat[good,bad,fail,eof]: [1000] 1 iss stat after: [1000] temp: B
2 iss stat[good,bad,fail,eof]: [1000] 2 iss stat after: [0001] temp: C
###
We can see the last reading is not fail/bad just eof meaning the last
reading is OK but no further reading is needed.
Here is the common way:
void test2(){
string s = "A B C "; // output is A B C C
// If string s = "A B C", then the output would be A B C
istringstream iss(s);
string temp;
int _i = 0;
while (iss>>temp)
{
cout << _i<< " iss stat after: [" << iss.good() << iss.bad() <
}
}
test2:
0 iss stat after: [1000] temp: A
1 iss stat after: [1000] temp: B
2 iss stat after: [1000] temp: C
【在 e*****r 的大作中提到】
: int main()
: {
: string s = "A B C "; // output is A B C C
: // If string s = "A B C", then the output would be A B C
: istringstream iss(s);
: string temp;
: while (!iss.eof())
: {
: iss >> temp;
: cout << temp << endl;
F*k
14 楼
吃!
正在做盐腌鼻涕虫
正在做盐腌鼻涕虫
e*r
15 楼
多谢。
你讲述的很详细。
the
【在 m********5 的大作中提到】
: why you use iss.eof()?
: The common way to do this is directly check after iss>>temp, because their
: can be fail, bad, whitespace, or eof. If either fail/bad signal is True, the
: temp is not valid.
: ###
: void test(){
: string s = "A B C "; // output is A B C C
: // If string s = "A B C", then the output would be A B C
: istringstream iss(s);
: string temp;
你讲述的很详细。
the
【在 m********5 的大作中提到】
: why you use iss.eof()?
: The common way to do this is directly check after iss>>temp, because their
: can be fail, bad, whitespace, or eof. If either fail/bad signal is True, the
: temp is not valid.
: ###
: void test(){
: string s = "A B C "; // output is A B C C
: // If string s = "A B C", then the output would be A B C
: istringstream iss(s);
: string temp;
g*o
19 楼
同学们怎么反应这么迟钝,都去海皮阿沃勒吗
B*a
33 楼
排
B*a
43 楼
上次你卷了他们三个?
r*n
48 楼
this office is the best place for me to enjoy life, do study and travel.
i have tons of PTO time and also very easy going life style. I always do my
personal things without using PTO. I go to DPS, DMV, etc using office hours.
I also do my study in office. I have my own office and nobody can see me.
I never feel stressed out in this job because it's so easy going. I like it
actually.
【在 a***x 的大作中提到】
: 然后还得跟人憋绿卡。这不撑的么。
:
: got
i have tons of PTO time and also very easy going life style. I always do my
personal things without using PTO. I go to DPS, DMV, etc using office hours.
I also do my study in office. I have my own office and nobody can see me.
I never feel stressed out in this job because it's so easy going. I like it
actually.
【在 a***x 的大作中提到】
: 然后还得跟人憋绿卡。这不撑的么。
:
: got
a*x
50 楼
知道需要跟人憋绿卡的时候。这不撑的么。
my
hours.
it
【在 r********n 的大作中提到】
: this office is the best place for me to enjoy life, do study and travel.
: i have tons of PTO time and also very easy going life style. I always do my
: personal things without using PTO. I go to DPS, DMV, etc using office hours.
: I also do my study in office. I have my own office and nobody can see me.
: I never feel stressed out in this job because it's so easy going. I like it
: actually.
my
hours.
it
【在 r********n 的大作中提到】
: this office is the best place for me to enjoy life, do study and travel.
: i have tons of PTO time and also very easy going life style. I always do my
: personal things without using PTO. I go to DPS, DMV, etc using office hours.
: I also do my study in office. I have my own office and nobody can see me.
: I never feel stressed out in this job because it's so easy going. I like it
: actually.
m*o
52 楼
rockfan, u r my idol!
m*o
54 楼
rockfan, u r my idol!
c*p
61 楼
为啥他们都包子们了,我的单数还不见?!
g*o
71 楼
原来又在打麻将,我睡觉去了,打麻将最没意思了,声音都不出,以为睡着了
l*f
74 楼
CHI!
k*e
84 楼
还赶得上包子么。。
c*s
90 楼
chicken wings, corn nuggets, 再加版大的包子,这个早晨没虚度。
t*g
91 楼
还有吗,早上起来,蹭个早点。
x*n
92 楼
同吃公款包子
o*0
93 楼
chi
i*n
94 楼
zan!
d*a
95 楼
pai
n*2
98 楼
求下午茶
r*a
100 楼
嘿,以为老四上菜了~
l*z
102 楼
吃
相关阅读
华为要把45岁以上的非管理人员都赶走,你们怎么看?[bssd]Wdong你之前是不是提过王培教授?码工,AI之外的事儿你怎么看?MITBBS上能找到在MIT研究研究机器人的同学或者教授吗?Time series big data大家觉得怎么存储比较好?cs这几个方向,哪个现在和未来的状况最好?js里怎么一批批地执行异步操作?现在最popular的JavaScript framework 是啥?[bssd]有本书加拿大和美国税收的一些区别 (转载)Visual Studio 2013新文件模板[bssd]万物皆数问个比较低级的问题吧tensorflow太扯了meteor能用es6写么?用meteor就不用flux了?Re: 码工就是吃青春饭的,我以前的公司有两三天不睡连续干的 (转载)几个前沿问题来,分析下这个垃圾邮件里面的代码DL一个基础问题:lua怎么样