VS Code configures the C locale

There are many softwares for writing C language programs. Beginners generally use IDE, which is the integrated development environment, which integrates editor, compiler, operating environment and debugging tools.

        (1) Windows IDE, it is recommended to use Dev C++, version 5.10; Code::Blocks.

        (2) MacOS needs to download the programming software Xcode from the AppStore.

VS Code configures the C language environment, the operation is as follows:

(1) Download and install VS Code

        Download and install Visual Studio Code, the standalone editor. This has nothing to do with Visual Studio.

        VS Code software download website: Visual Studio Code - Code Editing. Redefined

(2) Start VS Code and install 2 plugins

        Start the VS Code editor, you need to install 2 plug-ins to compile the code.

        Click Extensions on the left , search for the first plug-in : C/C++ , and click install. Function: syntax highlighting, recognize C language components. To run the code, you also need to search for and install a second plugin: code run .

(3) Create a new single source code file

        Directly create a single source code file, create a New File, and save it as a *.c file first.

        Then write to print hello world. Click Run in the upper right corner.

        The running results will be displayed in the OUTPUT area below.

(4) Establishment of multiple *.c files. ——workspace workspace

        VS Code does not have the function of creating a new workspace, so first create a new folder directory CT under the folder, then open VS Code, and open the newly created folder CT through open folder.

        (4.1) Create a file from scratch and name it main.c

        At this time, there are more *.vscode folders in the CT directory, which are about the configuration of the workspace.

        Write the required function code in main.c.

         (4.2) There are already files, how to add them.

                Copy the file to the CT directory, and VS Code will automatically recognize the newly added file.

                Clicking run at this time will fail to compile. Because it only recognizes the current main.c, and does not recognize eval() inside.

(5) Compile and run (gcc and make)

        Click View-----Terminal terminal

        Enter dir to see what files are there, which can be compiled with gcc.

        Enter gcc main.c eval.c -o eval   (compile the two *.c files here)

         After the compilation is complete, enter dir again and find that there are more eval.exe files.

         Enter ./eval (indicates the execution of eval in the current directory)——(you can’t just write eval,)

        No output was found. It is normal, because the function of the code is: when the calculation result is equal to 12, no exception is thrown.

         Note: - (cannot just write eval)

        Two *.c files can be compiled with gcc.

        But if there are many *.c files, you need to use Makefile

        Copy the downloaded Makefile into the CT directory,

         If you enter make directly, you will not find it. You must enter mingw32-make to get eval.exe

         The larger the program, the more it needs make to manage it.

Portal: VSCode configuration C language development environment, with MinGW installation package icon-default.png?t=M85Bhttps://mp.weixin.qq.com/s/hTXpcowl4yYh1j1erytoIQ

Guess you like

Origin blog.csdn.net/luyibing2017/article/details/127477332