How to compile notepad into c
Configure the compiler (Recommended learning: notepad use)
Download and install MinGW from the official website
change:
Select "mark for installation" of "mingw32-gcc-g -bin" and select "Apply Changes" of "Installation" in the upper right corner. There were no other problems when I didn't install the other items. Later, other problems arose and I had to ask for insurance before installing them. In total, just under 400MB was installed.
Edit environment variables
Control Panel\All Control Panel Items\System, Advanced System Settings→Environment Variables, Look for the PATH variable in the "Administrator's User Variables" column. If there is none, create a new one. If there is, edit it. The variable name is "PATH". Add "C:\MinGW\bin;" to the variable value based on the original value. This value is the same as each Personally, it depends on the location where MinGW is installed, which varies from person to person. The significance of ";" is that when the value of PATH has multiple items, use it to separate these items.
Two methods to check whether the first two steps are successful
Enter the cmd console and enter gcc -v or g -v to view The compiler version that has been added to the environment variables. It is normal to display the content in the yellow box, indicating that the first two steps were successful. Create a simple C source code file and make sure the code runs correctly. For example, Hello.cpp:
//Hello.cpp #include<iostream> using namespace std; int main() { cout<p> In the cmd console cd to the directory of the source code, then execute g Hello.cpp -o Hello.exe, and then execute the Hello.exe /k command. It can run normally. It shows that the first two steps are fine. <br>The former command is to use the g compiler to compile the source code and output the exe file to this directory. The latter command is to run the exe file (the /k parameter makes it stay in the program interface after running, while /c will cause It is closed. That is the comparison between keep and close). The first two commands can actually be combined into one using "&&", that is, g Hello.cpp -o && Hello.exe Hello.exe /k. <br>We are already more than half successful here, because as you can see, you can already compile and run the source code in the cmd console. To give Notepad this ability, you only need to let Notepad "execute the currently opened source file with cmd in one step" Compile and run commands" only. </p> <p><strong>Notepad adds run command</strong></p> <p>Open Notepad and press F5 to bring up "Run". Copy the command mentioned later and run it. It is recommended to save it with any name. </p> <p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/image/354/143/781/1566178726956986.png" class="lazy" title="1566178726956986.png" alt="How to compile notepad into c"></p> <p>You can also find "Run (R)" in the toolbar </p> <p>Referenced a lot of information about Notepad run commands and cmd commands, modified My last command is </p> <pre class="brush:php;toolbar:false">cmd /k pushd "$(CURRENT_DIRECTORY)" && g++ -o "$(NAME_PART).exe" "$(FULL_CURRENT_PATH)" && "$(NAME_PART)".exe & PAUSE & EXIT
(no branch, it is a whole command). To understand this command, you can divide it into six, that is:
cmd /k: open cmd console, let it stay after running the program without automatically closing.
pushd "$(CURRENT_DIRECTORY)": Change the working path to the path where the source file is located. For example, 'pushd E:\kkk' is equivalent to e: and then cd kkk in cmd. This command is in the source code This is especially important when you want to call a file in the same directory and only write a relative path. Because Notepad's default working path is its own installation path.
g -o "$(NAME_PART).exe" "$(FULL_CURRENT_PATH)": Call the compiler g .exe in the environment variable to compile the source code into an exe file with the same name and output it to the same path.
"$(NAME_PART)".exe: Run the executable file compiled from the source code.
PAUSE: Pause, prompt "Press any key to continue", and cooperate with the next command to achieve the effect of "Press any key to close". If neither of them is available, the program will close in seconds after running.
EXIT: Close the cmd console. If not, press any key to return to the cmd command console, waiting for the next command to be entered.
$(CURRENT_DIRECTORY) represents the path of the directory where the file is located.
$(NAME_PART) indicates the file name without the suffix part of the file.
$(FULL_CURRENT_PATH) represents the current complete file path.
Double quotation marks (half-width): used to prevent directories or file names from containing spaces.
"&&" and "&": The former means that the next command will be executed after the previous command is executed normally, and the next command will not be executed if it is abnormal; there is no need to worry about the latter. For example, the last two subcommands after dividing into six means that regardless of whether the source code is compiled and run successfully, the words "Press any key to continue" will appear, and the cmd console will be closed after pressing any key.
The above is the detailed content of How to compile notepad into c. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Notepad++ provides a variety of formatting options, including: 1. Automatic alignment: Ctrl + A After selection, Edit > Operation > Alignment; 2. Indentation: Tab/Shift + Tab or configured in settings; 3. Line break: Ctrl + J/Ctrl + Shift + J or configured in settings; 4. JSON formatting: Ctrl + Shift + F; 5. Case conversion, first letter capitalization, duplicate line deletion and other options.

How to open large files using Notepad++? Start Notepad++, click File > Open, and select the large file in the file browser. Common problems you may encounter: slow loading of files, "file too big" errors, insufficient memory, corrupted files. Ways to optimize performance: disable plug-ins, adjust settings, use multi-threading.

To find duplicate data in Notepad, just perform the following steps: 1. Load the file; 2. Press "Ctrl + F" to open the "Find" dialog box; 3. Enter text and select the "Find All" option; 4. Click "Find" Next" button; 5. Manually mark or copy duplicate data.

In Notepad++, you can perform file comparisons by installing the comparison plug-in. Specific steps include: 1. Install the comparison plug-in 2. Open the file 3. Start the comparison 4. Analyze the results 5. Take advantage of advanced features such as side-by-side comparison, ignore whitespace, and custom colors

Notepad provides a text comparison function that can compare the differences between two text files. The steps include: 1. Open two text files; 2. Enable the comparison function; 3. Compare the files; 4. View the comparison results.

Font size can be adjusted in Notepad by following these steps: 1. Open Notepad; 2. Go to the "Format" menu; 3. Select the "Font" option; 4. In the "Font" window, use the "Size" field to adjust the font size; 5. Click the OK button to apply the changes.

This article explains how to set Notepad++'s default encoding so that it automatically uses a specific encoding when you open a file. Specific steps include: Click the "Encoding" menu and select "Set Default Encoding". Select the desired encoding, such as UTF-8, from the Default Encoding dialog box. Click the "Save" button to complete the settings.

Aligning text in Notepad++ can be done through "Edit" > "Align" or Ctrl + L. The alignment options provided include: left, right, center, and both ends. You can also set the indent amount to further enhance alignment.
