Home > Backend Development > C++ > body text

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

Susan Sarandon
Release: 2024-11-08 05:50:02
Original
700 people have browsed it

in .vscode Folder :

My 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"
}
Copy after login

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"
}
Copy after login

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
}
Copy after login

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

code :

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

Terminal:

PS C:Users*OneDriveDocumentsINTERVIEW PREPDSA and Small Learnings> & 'c:Users**.vscodeextensionsms-vscode.cpptools-1.23.0-win32-x64debugAdaptersbinWindowsDebugLauncher.exe' '--stdin=Microsoft-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'

When I press F5, means i debug my C code, it not prints anything or neither take any inputs if scanf is there, if debugger is at scanf , and if i press F10 , then as shown in picture, Nothing happens. I can Only hover and see the variable value. I have installed

 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!
Copy after login

The above is the detailed content of C debugger Not able to Print or take Input when in debugger mode is On. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
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
Latest Articles by Author
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!