首頁  >  文章  >  後端開發  >  C 偵錯器在偵錯器模式開啟時無法列印或取得輸入

C 偵錯器在偵錯器模式開啟時無法列印或取得輸入

Susan Sarandon
Susan Sarandon原創
2024-11-08 05:50:02753瀏覽

在 .vscode 資料夾中:

我的lanch.json:

    "configurations": [
        {
            "name": "C/C++: gcc.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\MinGW\bin\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc.exe build active file"
        }
    ],
    "version": "2.0.0"
}

task.json :

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\MinGW\bin\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "compilerPath": "C:/MinGW/bin/gcc.exe"
        }
    ],
    "version": 4
}

C debugger Not able to Print or take Input when in debugger mode is On

代碼:

#include <stdio.h>
int main(){
int i;
scanf("%d", &i);
printf("You entered: %d\n", i);
return 0;
}

終端:

PS C:使用者*OneDriveDocumentsINTERVIEW PREPDSA 與小型學習> & 'c:Users**.vscodeextensionsms-vscode.cools-1.23.0-win32-x64deAdunchAdunchersAbugsdAdunchers. -MIEngine-In-caznmueg.sx2' '--stdout=Microsoft-MIEngine -Out-kpfaclzx.m3o''--stderr=Microsoft-MIEngine-Error-nq1rgwan.vxy''--pid=Microsoft-MIEngine-Pid- d12jsuyv.lf0''--dbgExe=C:MinGWbingdb.exe''- -interpreter=mi'

當我按F5 時,意味著我調試我的C 代碼,如果scanf 存在,如果調試器位於scanf ,並且如果我按F10 ,則它不會打印任何內容,也不會接受任何輸入,然後如圖所示,什麼事也不會發生。我只能將滑鼠懸停並查看變數值。我已經安裝

 set up,

 ```codeLLB```

 and code runner extensions, as well.

Also, If I not put debugger at scanf function: it waits for input ,but when i write something and hit enter, nothing happens, also the debugger not allow to step next step...And after that if i stop the debugger, then what ever i wrote in terminal ,shows there immediately. Example: if i wrote fffff and then stop debugger then that word executes in terminal!

以上是C 偵錯器在偵錯器模式開啟時無法列印或取得輸入的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn