Илья Дементьев
Self belief and hard work will always earn you success · 13.06
Hi everyone 😃
I'm starting a series of posts about C and ReactJS. Today, I'll show you how to execute C code using Notepad++ 💪
Sometimes, we don't need heavyweight tools like Visual Studio or Xcode to run simple C code. Check out Notepad as an easy alternative 😄
Let's break it step by step!
▶️ 1: Install MinGW-w64 First, you need to install MinGW-w64 on your computer, choose your system whether it 32-bit or 64-bit Windows. Once you done with that, type "pacman -S mingw-w64-ucrt-x86_64-gcc". It will install GNU Compiler Collection for the MinGW-w64 toolchain targeting the Universal C Runtime on a 64-bit architecture.
▶️Step 2: Add MinGW-w64 to System Environment Variables After installing MinGW-w64, you must add its path to the system environment variables. Here’s how you can do it: a) Open Advanced System Settings. b) Click on Environment Variables. c) In the System variables section, find the variable named Path, select it, and click Edit. d) Click New and add the following path: My path is C:\msys64\ucrt64\bin, replace it with yours path if it differs on your system.
▶️Step 3: Set Up NppExec in Notepad++ a) Open Notepad++. b) Go to Plugins Admin. c) Search for NppExec, select it, and click Install. After installing, go to Plugins -> NppExec and click Execute NppExec Script.
▶️Step 4: Execute Your C++ Code In the NppExec script window, paste the following code: ☛ a) NPP_SAVE -> This command saves the current file you are working on in Notepad++ ☛ b) CD $(CURRENT_DIRECTORY) -> This changes the directory to the current directory of the file you are working on. $(CURRENT_DIRECTORY) is a placeholder that gets replaced with the actual directory path. ☛ c) g++.exe -g "$(FILE_NAME)" -o "$(DEFAULT_OUTPUT_FILE)" -> This runs the g++ compiler, -g option includes debugging information in the compiled program, $(FILE_NAME) is a placeholder for the name of the current file you are working on, -o "$(DEFAULT_OUTPUT_FILE)" specifies the name of the output file, which in this case is output.exe. ☛ d) 1. CMD /C "$(DEFAULT_OUTPUT_FILE)" -> This runs the compiled executable file (output.exe) in a command prompt. CMD /C is used to execute the command and then terminate the command prompt. Anyway, you can call it different from output.exe....for example inheritance or Hello World 😁 haha
And FINALLY, save it and name it haha, for example "C/C++ Complile/Run". Your task is to find out how to run the script :)
https://www.linkedin.com/feed/update/urn:li:activity:7207024656887779328/
Вадим Черенёв
· 14.06
А что, под винду нет компиляторов, кроме как gcc под mingw? Вроде борландовский бесплатный был.
ответить
Алексей Шашев
15.06
Так еще есть clang, да и Visual C++ бесплатный.
ответить
еще контент автора
еще контент автора
Илья Дементьев
Self belief and hard work will always earn you success · 13.06
войдите, чтобы увидеть
и подписаться на интересных профи