Gao - not understood 2019-11-16 12:12 采纳率: 0%
浏览 698

VS code 调试C语言代码

我用VS code 学习C语言,想打印出 Hello World,可是调试之后出现了一个.exe 文件,那个黑色窗口也没有显示出来.
打开.exe文件后出现乱码, 有没有大佬帮我看一下?

这是hello.exe出现乱码
图片说明

这是launch.json 文件代码

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "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": "D:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

这是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": "D:\\MinGW\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

我的电脑已经装好了C/C++插件和 run code插件, 以及相应的MinGW, 但是运行的时候那个黑窗窗出不来, 运行后又出现了.exe 文件, 却是乱码.

  • 写回答

2条回答 默认 最新

  • 「已注销」 2019-11-16 12:39
    关注

    添加系统环境path变量MinGW的bin文件夹,run code 不需要 任何启动配置。切到 .c 文件 点击右上角三角形就可以了。

    图片说明

    图片说明

    如果系统是x86或x64,选择"x86_64", 否则选择"i868"。

    posix: 启用 c++11多线程功能。

    win32: 没有C++11多线程功能

    #include <stdio.h> 
    void main()
    { 
    printf('hello world \n');
    getchar();
    }
    

    改一下代码试一下,添加一行" getchar(); " ,意思是等待输入字符。

    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波