Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The method of compiling and running c in notepad

Shulou Source: shulou.com Published: 2022-06-02 18:46:57 09月16日 Update

Editor to share with you the method of notepad compilation and running c, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

How does notepad compile and run c?

Step 1: write c code

# includeint main () {printf ("hello world"); return 0;}

Step 2: press F5 to run for macro definition

Cmd / k gcc-o "$(CURRENT_DIRECTORY)\ $(NAME_PART) .exe" $(FULL_CURRENT_PATH) "& & CLS & &" $(CURRENT_DIRECTORY)\ $(NAME_PART) .exe "& PAUSE & EXIT

Press enter to get the result.

After you choose to save, you can choose a shortcut key, and next time you can press the shortcut key directly to run perfectly!

Step 3: run perfectly

Supplement

Compile:

Cmd / k gcc-Wall-o "$(CURRENT_DIRECTORY)\ $(NAME_PART) .exe"$(FULL_CURRENT_PATH)" & PAUSE & EXIT

Run:

Cmd / k "$(CURRENT_DIRECTORY)\ $(NAME_PART) .exe" & PAUSE & EXIT

About the script line: cmd / k gcc-o "$(CURRENT_DIRECTORY)\ $(NAME_PART) .exe"$(FULL_CURRENT_PATH)" & & CLS & & "$(CURRENT_DIRECTORY)\ $(NAME_PART) .exe" & PAUSE & EXIT

Cmd / k pops up the cmd window and executes subsequent instructions. & and & & indicate connectivity, indicating that multiple lines of instructions are combined into one line.

Gcc-o "$(CURRENT_DIRECTORY) $(NAME_PART) .exe" $(FULL_CURRENT_PATH) "compiles the .exe file and outputs the directory where the source file is located. Note that quotation marks are required in order to work properly even if there are spaces in the directory and file name.

& & CLS clear the screen. The meaning of & & is that there is an error in the previous statement and the sentence will not be executed.

& "$(CURRENT_DIRECTORY) $(NAME_PART) .exe" runs the .exe file you just generated. If there is a previous compilation error, it will not run.

& PAUSE pauses and prompts "press any key to continue". It will be executed here, regardless of whether there is an error or not. So what we see is a compilation error, a window that displays an error message and pauses.

& EXIT exits.

The above is all the contents of this article "how to compile and run c in notepad". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Run compile error file article method content shortcut key instruction directory generate select one line not much code function information most quotation marks situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei macOS vpn Redmi