0

interrupt cin>>str while loop

when I use ctrl+d, it shows "process finished with exit code 0" and the code following the loop will never be excuted(the cout sentence). What if I want to continue execution of this program? string str; while(cin >> str); cout << "outside of the loop"; return 0 environment: CLion for Linux Thanks!

24th Jul 2017, 5:17 AM
Yongliang He
Yongliang He - avatar
2 Respostas
+ 1
Add some condition to while loop. For example when user inputs some string "stop", you can do 'break;' and step out from the while loop.
24th Jul 2017, 7:00 AM
soman
0
@soman Yes it works, but I know from other place that ctrl + d should have solved the problem: it will interrupt the loop but not terminate the whole program. what's the result on your machine?
24th Jul 2017, 7:29 AM
Yongliang He
Yongliang He - avatar
Quente hoje
.
1 Votes
What?
0 Votes
HTML
0 Votes
FRC Coding?
1 Votes
Quiz duel
0 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes
Create Agent
0 Votes