VSCode快速配置C语言环境-创新互联
                                            
                                                 1.在VSCode中安装C/C++插件 2.下载mingw64
2.下载mingw64
本文名称:VSCode快速配置C语言环境-创新互联
文章路径:http://www.scyingshan.cn/article/dcgosg.html
                                            
                                         2.下载mingw64
2.下载mingw64MinGW-w64官方网站首页





将下载好的mingw64解压到指定的目录,我的路径是C:\Program Files\mingw64,然后配置环境变量 将目录C:\Program Files\mingw64\bin加入到环境变量path里(注意修改为自己的mingw64路径,具体到bin文件夹)

打开命令行输入gcc -v,出现以下信息说明mingw64配置成功


点这里可以直接下载 再修改路径
.vscode文件下载
注意:c_cpp_properties.json和launch.json 需要修改路径(1)c_cpp_properties.json配置
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "C:\\Program Files\\mingw64"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=6",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "intelliSenseMode": "windows-gcc-x64",
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "${workspaceRoot}",
                    "C:\\Program Files\\mingw64"
                    //此处修改为自己mingw64的路径
                ]
            }
        }
    ],
    "version": 4
}(2)launch.json配置
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "cmd",
            "preLaunchTask": "echo",
            "args": [
                "/C",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "&",
                "echo.",
                "&",
                "pause"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole":true
        },
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw64\\bin\\gdb.exe",//修改为自己电脑的gdb路径
            "preLaunchTask": "echo",//这里和task.json的label相对应
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
 
        }
    ]
}(3)tasks.json配置
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", 
                "${file}", 
                "-o", 
                "${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"//解决中文乱码
            ]
        }
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared", 
        "showReuseMessage": true,
        "clear": false
    }
}#includeint main()
{
   printf("Hello, World! \n");
   return 0;
} 
如果打印中文乱码,请看下面这篇文章
vscode 解决C语言printf打印中文乱码问题
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
本文名称:VSCode快速配置C语言环境-创新互联
文章路径:http://www.scyingshan.cn/article/dcgosg.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 