Terminate a c++ program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Terminate a c++ program

how can I terminate a c++ programme when a condition is met

26th Sep 2017, 5:31 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
6 Answers
+ 3
found it we can use stdlib.h and exit(0); yeeaaahhhhh!
26th Sep 2017, 5:43 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 3
oh!!! thnq very much @yash and @frederic sry I didn't got u U were right I thought that (return 0) can only be used at the end of a program... thnx guys
28th Sep 2017, 3:53 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 2
the proper way to terminate your main function is return 0;
26th Sep 2017, 11:02 PM
Frédéric Charette
Frédéric Charette - avatar
+ 2
@dhiman I think I already found it (the very first ans Of this question) btw thnx for ur help
4th Oct 2017, 6:12 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
no, I was asking :- how to terminate the entire code when a specific condition is met without running the code after that condition
27th Sep 2017, 3:55 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
You can use exit () which is defined in the library function stdlib.h Hope i was clear enough
4th Oct 2017, 5:30 AM
dhiman mishra
dhiman mishra - avatar