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 楼
吃
相关阅读
混linux+open source三个月有感,对开发人员来说就是个大坑啊!java DL,ML微软AI 能编程。。。公司配的笔记本,如何安全地上黄色网站?多大的项目可以考虑microservice?Linux system admin 和码工那个好知乎网页的防复制功能是怎么实现的?大家spring batch都是怎么管理的,有ui的tool吗word2vec 中skip gram 问题请教发现了个微软3位同胞的强文 Cat Head Detection深度学习 model compression自动码农机器永远也不会出来 (转载)自己搞搞ML,训练nn的话 是自己攒个高配置服务器好是直接用g cloud好?码工,AI之外的事儿你怎么看?[bssd]有本书能否请推荐个社区系统可以双向同步Slack的?block chain和iot中国式员工:20岁你玩命干,30岁你快滚蛋(zz) (转载)python pickle 目的是什么请问Java和Java EE的区别是啥?