Home > Development Tools > VSCode > body text

How vscode runs c language

下次还敢
Release: 2024-04-03 04:36:17
Original
1302 people have browsed it

Steps to run C language program in VSCode: Install C/C extension. Create a C language file named "main.c". Enter the C language code. Configure the "tasks.json" file to compile C code. Run the "build" task to compile and run the program.

How vscode runs c language

Run the C language program in VSCode

Step 1: Install the extension

  • Open VSCode and go to the "Extensions" tab.
  • Search for "C/C" extension and click the "Install" button.

Step 2: Create a C language file

  • Open VSCode, click "File" > "New", and then select "File" .
  • Name the file "main.c".

Step 3: Write C language code

  • In the "main.c" file, enter the following code:
<code class="c">#include <stdio.h>

int main() {
  printf("Hello, world!\n");
  return 0;
}</code>
Copy after login

Step 4: Configure the task

  • Click the "Task" tab in the lower left corner of VSCode.
  • Right-click on an empty area and select "Create Task".
  • In the "tasks.json" file that appears, paste the following content:
<code class="json">{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "type": "shell",
      "command": "gcc ${file}"
    }
  ]
}</code>
Copy after login

Step 5: Run the program

  • Click the "build" task in the "Tasks" tab.
  • VSCode will compile C language code and generate an executable file.
  • In Terminal, enter the following:
<code class="bash">./main</code>
Copy after login

This will run the C language program and print out "Hello, world!".

The above is the detailed content of How vscode runs c language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!