The difference between include "" and include<> in C language (custom header file, preset header file)

Article Directory

New console application

Both Win32 Application and Win32 Console Application are programs that work in a 32-bit Windows environment. among them:

(1) Win32 Application is an ordinary and common window application. Of course, some interfaces are made more personalized, such as circular and irregular shapes... They are all the so-called GUI (Graphics User Interface), we The control can be completed by clicking with the mouse. Win32 Application is prepared for you to develop windows applications. The program takes WinMain() as the entrance, #include<windows.h>, and can use win32 API functions.
(2) Win32 Console Application (win32 console application) often appears like an MS-DOS window (called command prompt in XP). We have to use the keyboard to enter various commands to use it. It is similar to a pure DOS program. The difference is: it is 32-bit; or CUI (Character User Interface). The console program uses main() as the entry point and cannot use win32 API functions.

Open the Visual C++ 6.0 development environment and create a new Win32 Console Application.

Insert picture description here

Custom header file

Insert picture description here


The newly created header file is located in the Header Files of the project folder.

Insert picture description here

Edit header file

Double-click to open, in the header file, you can customize and write some of our own functions.

Insert picture description here


Complete function code:


//求两个数之和
int add(int a,int b)
{
	return a+b;
}

//欧拉公式

int IsPrime(int a)
{
	int i;
	for(i=2;i<=a/2;i++)
	    if (a%i==0) return 0;
	    return 1;
}

//阶乘

double fact(int n)
{
	double F=1.0;
	if (n==0) return 1.0;
	F=n*fact(n-1);
	return F;
}

//阶乘倒数之和

double fact(int n)
{
	int i ;double F=1.;
	for (i=1;i<=n;i++)
	{
		F=F*i;
	}
		return F;
}

//水仙花数

int sx(int n)
{
	int m,a,b,c;
	m=n;
      a=n/100;n=n%100;
	  b=n/10;n=n%10;
	  c=n;
		if(a*a*a+b*b*b+c*c*c==m)
			return 1;
		else
			return 0;
}

Include header files and call functions in the project

There are two ways to use the #include command in C language. The difference between #include <> and #include ”” is that it is used in different ways.

One is to enclose the header file name with "<>" after the include directive #include. This method is used for standard or system-supplied header files. Search for the header file where the system standard header file is saved.
The other is to include the header file with double quotes "" after the include directive #include. This method is often used with the programmer's own header file. When using this format, the C compiler first searches for a header file with the specified name in the current directory, and then searches from the standard header file directory.

Create a new original file a1.c, the code is as follows:

#include<stdio.h>
#include"h1.h"
main()
{
	int sum;
	sum=add(3,5);
	printf("%d\n",sum);
}
Insert picture description here

Standard library header files, calling functions

You can also move a custom header file to the standard library for reference.

C:\Program Files (x86)\Microsoft Visual Studio\VC98\Include
Insert picture description here


For the header file reference located in the standard library, to use #include<h1.h>, the complete code is as follows:

#include<stdio.h>
#include<h1.h>
main()
{
	int sum;
	sum=add(3,5);
	printf("%d\n",sum);
}