vscode->学习c语言的利器

学习编程,一款界面友好,debug调试是必须的,不然没有学下去的动力,一下是个人配置经验
1:下载mingw64,具体下载过程百度可以解决
下载好后,配置环境变量
2:官网下载vscode
3:打开vscode,在这里插入图片描述
在2中搜索c/c++插件,会发现有很多个,选择下载次数最多的那个就是了,点击install
3:新建一个文件夹,在里面新建一个以.c为后缀的c文件,代码随意,例如代码

#include<stdio.h>
int main()
{
	printf("世界,你好");
	return 0;
}

写完后,在这里插入图片描述
点击箭头所指,按顺序会弹出选项,选择C++(GDB/LLDB),会生成一个launch.json文件,文件改为如下

   "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw64\\bin\\gdb.exe",//注意,这个不同路径可能不同,你们的不用改这
            "setupCommands": [
                {
                    "description": "Enable prety-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

然后返回c文件,按f5运行,会弹出找不到任务英文界面,点击第一个配置任务,然后自动生成tasks,json,文件改成如下

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc.exe build active file",
            "command": "C:\\Program Files\\mingw64\\bin\\g++.exe",路径不同,不用改
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\Program Files\\mingw64\\bin"//路径不同,不用改
            }
        }
    ]
}

改完后,按ctrl+s保存,返回c文件,按f5运行,成功!
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值