|
2 | 2 | title: "Walkthrough: Compiling a Native C++ Program on the Command Line" |
3 | 3 | description: "Use the Microsoft C++ compiler from a command prompt." |
4 | 4 | ms.custom: "conceptual" |
5 | | -ms.date: "04/02/2020" |
| 5 | +ms.date: 03/25/2021 |
6 | 6 | helpviewer_keywords: ["native code [C++]", "Visual C++, native code", "compiling programs [C++]", "command-line applications [C++], native"] |
7 | 7 | ms.assetid: b200cfd1-0440-498f-90ee-7ecf92492dc0 |
8 | 8 | --- |
@@ -57,11 +57,11 @@ Before you can build a C or C++ program on the command line, verify that the too |
57 | 57 |
|
58 | 58 | ### Create a Visual C++ source file and compile it on the command line |
59 | 59 |
|
60 | | -1. In the developer command prompt window, enter `md c:\hello` to create a directory, and then enter `cd c:\hello` to change to that directory. This directory is where your source file and the compiled program are created in. |
| 60 | +1. In the developer command prompt window, enter `md c:\hello` to create a directory, and then enter `cd c:\hello` to change to that directory. This directory is where both your source file and the compiled program get created. |
61 | 61 |
|
62 | 62 | 1. Enter `notepad hello.cpp` in the command prompt window. |
63 | 63 |
|
64 | | - Choose **Yes** when Notepad prompts you to create a file. This step opens a blank Notepad window, ready for you to enter your code in a file named hello.cpp. |
| 64 | + Choose **Yes** when Notepad prompts you to create a new file. This step opens a blank Notepad window, ready for you to enter your code in a file named hello.cpp. |
65 | 65 |
|
66 | 66 | 1. In Notepad, enter the following lines of code: |
67 | 67 |
|
@@ -97,7 +97,10 @@ Before you can build a C or C++ program on the command line, verify that the too |
97 | 97 |
|
98 | 98 | ``` |
99 | 99 |
|
100 | | - The dates and other details will differ on your computer. If you don't see your source code file, *hello.cpp*, make sure you've changed to the *c:\\hello* directory you created. In Notepad, make sure that you saved your source file in this directory. Also make sure that you saved the source code with a *`.cpp`* file name extension, not a *`.txt`* extension. |
| 100 | + The dates and other details will differ on your computer. |
| 101 | + |
| 102 | + > [!NOTE] |
| 103 | + > If you don't see your source code file, *`hello.cpp`*, make sure the current working directory in your command prompt is the *`C:\hello`* directory you created. Also make sure that this is the directory where you saved your source file. And make sure that you saved the source code with a *`.cpp`* file name extension, not a *`.txt`* extension. Your source file gets saved in the current directory as a *`.cpp`* file automatically if you open Notepad at the command prompt by using the **`notepad hello.cpp`** command. Notepad's behavior is different if you open it another way: By default, Notepad appends a *`.txt`* extension to new files when you save them. It also defaults to saving files in your *Documents* directory. To save your file with a *`.cpp`* extension in Notepad, choose **File** > **Save As**. In the **Save As** dialog, navigate to your *`C:\hello`* folder in the directory tree view control. Then use the **Save as type** dropdown control to select **All Files (\*.\*)**. Enter *`hello.cpp`* in the **File name** edit control, and then choose **Save** to save the file. |
101 | 104 |
|
102 | 105 | 1. At the developer command prompt, enter `cl /EHsc hello.cpp` to compile your program. |
103 | 106 |
|
|
0 commit comments