调试C程序时VS Code不显示输出

时间:2020-08-04 17:52:07

标签: c gcc gdb

我编写了一个简单的C程序:

[vagrant@localhost ~]$ kubectl get deployment --namespace=development
No resources found in development namespace.

然后,我使用$ cat ~/.kube/config apiVersion: v1 clusters: - cluster: certificate-authority-data: <my certificate-authority-data> server: https://2C1A77626A2087EBA1D1123EA9398DAF.gr7.ap-northeast-1.eks.amazonaws.com name: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl contexts: - context: cluster: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl user: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl name: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl current-context: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl kind: Config preferences: {} users: - name: arn:aws:eks:ap-northeast-1:056844949861:cluster/eksworkshop-eksctl user: exec: apiVersion: client.authentication.k8s.io/v1alpha1 args: - --region - ap-northeast-1 - eks - get-token - --cluster-name - eksworkshop-eksctl - --role - arn:aws:iam::056844949861:role/k8sDev command: aws 命令从GCC使用编译器构建了程序,并使用GDB配置对其进行了调试。除非我在#include <stdio.h> int main(void){ char first[20]; char last[20]; printf("Enter first name: "); scanf("%s", first); printf("Enter last name: "); scanf("%s", last); printf("Hello %c %c. \n", first, last); return 0; } 中设置gcc.exe build active file,否则调试控制台中没有输出,但是如果这样做,我将无法检查程序是否正常运行,因为控制台窗口会在我关闭后立即关闭输入了字符串。

如何解决此问题并确保可以正确调试程序?

0 个答案:

没有答案