You will learn how to create and maintain NP library header files
Declare all your functions in myNP_tutorial.h
Define all your functions in myNP_tutorial.c
Include your library in main source C_createHeader_example.cpp
Don't worry about the file extension of *.cpp or *.c
You can use either extension with Visual Studio for Numerical Programming course
Step 1. Create Workspace Folder
Create a local directory for programming
We will create the main directory under
C:\Users\yourID\source\repos
e.g. C:\Users\ykkim\source\repos
You can search for 'repos' in window menu
This is where your assignment projects should be located.
For this tutorial, let us create the new workspace directory as
Name the directory as "NP"
A name that clearly shows the course name
For this course, create the workspace sub-directory as
e.g.
C:\Users\ykkim\source\repos\NP\tutorial
C:\Users\ykkim\source\repos\NP\include
Step 2. Create a tutorial C-prog Project
Under ..\NP\tutorial directory, create a new folder named as TU_CreateHeader
i.e.: C:\Users\yourID\source\repos\NP\tutorial\TU_CreateHeader
Create a new empty project in Visual Studio Community
Name the project as TU_createHeader
Create a new C/C++ source file for main()
Name the source file as TU_createHeader_example.cpp
Paste the following code
Compile and Run the program.
It should display the vector x[] values properly.
Step 3. Create library header files
Under the directory of \include, create new files or copy myNP_tutorial.cpp and myNP_tutorial.h.
C:\Users\yourID\source\repos\NP\include
You can paste codes below
Your library header files, and project source files should be located as
Step 4. Include your library header files in VS code
์๋ฃจ์
ํ์๊ธฐ(Solution Explorer) > ํค๋ํ์ผ > ์ถ๊ฐ > ๊ธฐ์กดํญ๋ชฉ
../NP/include/ ํด๋์์ myNP_tutorial.h, myNP_tutorial.cpp ์ ํ
3. Modify the header file include path
Step 5. Include your Header files in the main code
In the above main() program, include your header library by finding the path.
Now, you need to delete the function definition of printVec() in main(), for we have included the function from the header library file.
The main source file should be modified as
Compile and run the program.