Vscode解决中文乱码和多文件操作

发布时间 2023-12-17 20:55:48作者: yiye_zhiqiu

一、解决多文件操作

2.然后创建一个main文件、一个func.h文件、一个func.c文件

分别写上代码这是main.c

这是func.c文件

这是func.h文件

二、配置launch.json和tasks.json文件

 

将下面这个json文件复制拷贝到launch.json去:
launch.json

{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "E:\\ mingw64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 生成活动文件"
}
]
}

 

 将下面这个task.json文件复制拷贝到task.json文件里面去:
task.json

 

{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "E:\\ mingw64\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${fileDirname}\\*.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-fexec-charset=GBK"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}

分别是 

"${fileDirname}\\*.c"
"-fexec-charset=GBK"
 
配置好然后运行

 

 有问题私聊