Could someone please tell me how I can run my C++ code using Command prompt? How should I open it, and what I need to write?
And if there are more than one text files in my code including input data, how I can choose one of them to run that one?

Well you can either use command line arguments and code your program to accept and use those or you can just call you program and have the program ask you for what it needs.

// example of ussing command line arguments
c:\programFolder\program.exe -inputFile input.txt -outputFile output.txt
// program output here


// example of programing questions
c:\programFolder\program.exe // press enter
Please specify the input file: // enter the input filename and press enter
Please specify the output file: // enter the output filename and press enter
// program output here

I think my question was not clear.
My code is complete, I dont need to add sth to it, just I dont know how to open command prompt and what I need to write in it to address the code directory and run my text file, which includes input data.

Edited 1 Year Ago by rela

Well to open command promp you can simply do: [windows key] + R and then type in cmd and click ok. This will open up CMD for you.

You say "run my text file", well I'm not sure if you can "run" a text file, but you can open it to read from it.
In the cmd that you opened, type type text_file_name.txt or notepad text_file_name.txt

If you want your program to read from the file and specify that via command line, then you need to follow NathanOliver advice.

This article has been dead for over six months. Start a new discussion instead.