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 楼
吃
相关阅读
Tensorflow course (FREE Deep Learning)JS 的meteor 能上prod么请教LiteIDE如何设置才能Jump to Declaration 到新建的package问一道狗家Boggle变形难题 (转载)要不还是搞俱乐部算了share a aws account有没有 node 的站内信轮子card.com手机app源代码:ionic/angulargo 的坑(转载)java 这种破烂语言做的产品真心维护难 (转载)请教一个问题docker有什么新进展?Parse 要关了弱问下,12306为何不用队列系统解决?C++14新特性有dynamo大牛吗?老邢新的手机客户端上线了继续掐12306FLAG这些公司招码农会查信用记录吗?stackexchange疯了