How to run cmd with pre written commands in c++??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to run cmd with pre written commands in c++???

Hey guys! I want to know how to run cmd with prewritten commands. I want to do this using c++. If anyone could help with the code it would be a huge help. Thank you.

4th Oct 2019, 12:49 PM
Shrehan Raj Singh
Shrehan Raj Singh - avatar
2 Answers
+ 1
hi Shrehan Raj Singh you have already tagged system() in question... so, pass whatever you want to execute to system and it would get executed... if you are willing to wait for console closed after your result, pause can be used or get input can be used... below article might help you : https://www.geeksforgeeks.org/system-call-in-c/ I hope I have not misunderstood your question
5th Oct 2019, 7:07 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ketan Lalcheta. If u could give an example code then it would be really helpful
13th Oct 2019, 5:50 AM
Shrehan Raj Singh
Shrehan Raj Singh - avatar