c++visual-studiocode-templates

How can I make a header file appear on every new project


I'm very new to programming so hopefully I don't sound too dumb. I'm using visual studios to learn on and reading Bjarne Stroustrup's book "Programming Principles and Practice Using C++" and the book uses a header file called "std_lib_facilities.h" for every example. I've been copying the file into every single program manually and its getting kind of tedious. Is there any way to setup visual studios to were when I create a new project the header file will just automatically be there?


Solution

  • Yes, There is a way to add automatically the additional libraries and header files into every project you create.

    Navigate the window into MSBulid\v4.0 by using the below command in run window

    %localappdata%\Microsoft\MSBuild\v4.0

    Then you can find the Microsoft.Cpp.Win32.User.props

    Right click the Microsoft.Cpp.Win32.User.props and open with notepad or notepad++

    <ImportGroup Label="Property sheets"/>
        <PropertyGroup>
            <IncludePath> header file path </IncludePath>
        <LibraryPath> library Path </LibraryPath>
    </PropertyGroup>
    

    Add the above code in Microsoft.Cpp.Win32.User.props inside tag. And save the Microsoft.Cpp.Win32.User.props

    Open the Visual Code in Admin

    Have a nice day :)