How to Compile a C++ With CMD & CL
- 1). Click the Windows "Start" button and type "cmd" in the text box. Press "Enter" to open the MS-DOS command line.
- 2). Type "cd path" where "path" is the location of your compiler program. For instance, if your compiler is installed in "c:\cplusplus," type "cd cplusplus" and press "Enter." The prompt moves to the directory.
- 3). Type "cl /EHsc file.cpp" where "file.cpp" is your C++ source code. The compiler uses the CPP file to create an EXE file.
- 4). Type "file.exe" in the command prompt where "file.exe" is the new file created by the compiler. The compiler automatically names the EXE file the same name as the CPP file. Typing the EXE file into the command prompt runs the code on your computer.