所以我目前正在学习C并完成一本书 . 我所涉及的章节涉及在不同文件中分离函数等,而不是将它们保存在主文件中 . 所以为此,我想创建一个子文件夹来保存所有这些文件,而不是让它们通过主文件夹(在C中编程)这是目录概述的截图,第4章文件夹是我试图的子文件夹努力工作 .

Picture of folder layout

c_cpp_properties.json文件:

{
    "configurations": [
        {
            "name": "Win32",
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
                ],
                "limitSymbolsToIncludedHeaders": true
            },
            "includePath": [
                "${workspaceFolder}"

            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

tasks.json文件:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build hello world",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "helloworld.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },

        {
            "label": "build the main grader file",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "main_grader.cpp"
            ],
            "group" :{
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

我已经尝试了很多不同的方法,但我无法弄清楚如何给设置文件提供正确的路径或者它需要能够在main_grader.cpp文件的第4章文件夹中运行简单的hello world程序 .

我继续收到的错误是:

g++.exe: error: main_grader.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
The terminal process terminated with exit code: 1

我怎样才能正确地将子文件夹链接到我的main(在C语言中编程)文件夹才能运行代码?