interrupt cin>>str while loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answers
+ 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