Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile C Program under window Command Line

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to compile C programs under the window command line". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to compile C programs under the window command line" together!

For example: Write code in Notepad++:

Compile and run code in a black window:

Here, the compilation command is:

gcc hello.c

The generated executable file defaults to a.exe, and you can run the executable program by entering a.exe. Similarly, you can also add the-o parameter to rename a.exe. For example, the executable file generated by compiling hello.c is named hello.exe. The compilation command is:

gcc hello.c -o hello.exe

At this point, you can output hello.exe to run the program, such as:

After learning this compilation method, it is similar to compile under Linux environment, and the compiled commands are the same. I have shared the installation configuration method of this environment before, and some friends may not know how to configure it (please check the configuration method to develop C programs using Notepad++), and do not know how to use it.

This is not, yesterday a friend asked me how to switch the path in the black window, because it will not switch the path so I can not find the location of the code file. Now teach everyone how to switch paths:

(1) First of all, you need to know how to switch drive letters. Example of switching drive letters:

(2) Secondly, you can find the location of your code under the drive letter, for example, my code is under the D:\c_test path, then I can switch to the D:\c_test path as follows:

Alternatively, you can cd directly to the absolute path to the directory where your source code is located, such as:

In addition, there are two tips to tell you:

(1) Tab has a complement function, for example, you output cd c_, and then press Tab to automatically complement: cd c_test.

(2) If you don't remember the name of the folder, you can enter dir command (similar to ls command in linux system) to view all files and folders under the current folder, such as:

That's one way to switch to the source path in a black window, and if you can't, there's another, simpler way:

In Notepad, you can easily open your source code path in a black window:

Now that we've talked so much, let's talk about how to compile multiple files by the way. In fact, it is similar to compiling a file. To compile multiple files, you can add the files to be compiled to the compilation command, such as:

gcc cJSON.c json_parse_now.c -o test.exe

This command compiles the linked JSON.c and json_parse_now.c files simultaneously.

Thank you for reading, the above is "how to compile C program under the window command line" content, after the study of this article, I believe we have a deeper understanding of how to compile C program under the window command line, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report