Calls in the source of your own header files, how to realize the

This is the source code.
#include <stdio.h>
#include <ceshitou.h>
void main()
{
ceshitou();
}

I set up a ceshitou.h header file, as follows
void mytou()
{
printf("Test the success of");
}

Want to call header file in the source of guidance, not for success
Calls in the source of your own header files, how to realize the

Started by Quentin at February 05, 2016 - 8:00 PM

no such file or directory
The header file will be saved to what position to find?

Posted by Quentin at February 17, 2016 - 8:14 PM

Is it right? VS, if this is the case you may not put this header file is added to the project to go inside the file, drag in is good

Posted by Karida at November 19, 2016 - 3:03 PM

#include <ceshitou.h>
Change
#include "ceshitou.h"

Posted by Silvester at December 01, 2016 - 3:44 PM

#3 positive solutions
<>Look only from the standard directory
""Range is wide.

Posted by Spike at December 11, 2016 - 4:01 PM

The #include Directive
The #include directive tells the preprocessor to treat the contents of a specified file as if those contents had appeared in the source program at the point where the directive appears. You can organize constant and macro definitions into include files and then use #include directives to add these definitions to any source file. Include files are also useful for incorporating declarations of external variables and complex data types. You only need to define and name the types once in an include file created for that purpose.

Syntax

#include "path-spec"

#include <path-spec>

The path-spec is a filename optionally preceded by a directory specification. The filename must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.

Both syntax forms cause replacement of that directive by the entire contents of the specified include file. The difference between the two forms is the order in which the preprocessor searches for header files when the path is incompletely specified.

Syntax Form Action
Quoted form This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of whatever files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.
Angle-bracket form This form instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then along the path specified by the INCLUDE environment variable.


The preprocessor stops searching as soon as it finds a file with the given name. If you specify a complete, unambiguous path specification for the include file between two sets of double quotation marks (" "), the preprocessor searches only that path specification and ignores the standard directories.

If the filename enclosed in double quotation marks is an incomplete path specification, the preprocessor first searches the "parent" file's directory. A parent file is the file containing the #include directive. For example, if you include a file named file2 within a file named file1, file1 is the parent file.

Include files can be "nested"; that is, an #include directive can appear in a file named by another #include directive. For example, file2, above, could include file3. In this case, file1 would still be the parent of file2 but would be the "grandparent" of file3.

When include files are nested, directory searching begins with the directories of the parent file and then proceeds through the directories of any grandparent files. Thus, searching begins relative to the directory containing the source currently being processed. If the file is not found, the search moves to directories specified by the /I compiler option. Finally, the directories specified by the INCLUDE environment variable are searched.

The following example shows file inclusion using angle brackets:

#include <stdio.h>

This example adds the contents of the file named STDIO.H to the source program. The angle brackets cause the preprocessor to search the directories specified by the INCLUDE environment variable for STDIO.H, after searching directories specified by the /I compiler option.

The following example shows file inclusion using the quoted form:

#include "defs.h"

This example adds the contents of the file specified by DEFS.H to the source program. The double quotation marks mean that the preprocessor searches the directory containing the parent source file first.

Nesting of include files can continue up to 10 levels. Once the nested #include is processed, the preprocessor continues to insert the enclosing include file into the original source file.

Microsoft Specific

To locate includable source files, the preprocessor first searches the directories specified by the /I compiler option. If the /I option is not present or fails, the preprocessor uses the INCLUDE environment variable to find any include files within angle brackets. The INCLUDE environment variable and /I compiler option can contain multiple paths separated by semicolons (;). If more than one directory appears as part of the /I option or within the INCLUDE environment variable, the preprocessor searches them in the order in which they appear.

For example, the command

CL /ID:\MSVC\INCLUDE MYPROG.C

causes the preprocessor to search the directory D:\MSVC\INCLUDE for include files such as STDIO.H. The commands

SET INCLUDE=D:\MSVC\INCLUDE
CL MYPROG.C

have the same effect. If both sets of searches fail, a fatal compiler error is generated.

If the filename is fully specified for an include file with a path that includes a colon (for example, F:\MSVC\SPECIAL\INCL\TEST.H), the preprocessor follows the path.

For include files specified as #include "path-spec", directory searching begins with the directory of the parent file and then proceeds through the directories of any grandparent files. Thus, searching begins relative to the directory containing the source file containing the #include directive being processed. If there is no grandparent file and the file has not been found, the search continues as if the filename were enclosed in angle brackets.

END Microsoft Specific

Posted by Jeff at December 25, 2016 - 4:58 PM

Change the void main()
{
mytou();
}

Posted by Dana at January 01, 2017 - 5:54 PM

1 if the file ceshitou.h and called it *.c file in the same folder, #include <ceshitou.h> to #include "ceshitou.h" ,
2 if the file ceshitou.h and called it the *.c file is not in the same folder, such as the path for the d:\MyCHead\ceshitou.h, the #include <ceshitou.h> to #include "d:\MyCHead\ceshitou.h" ,

Note: the header file that contains the form: a.#include <stdio.h> /*stdio.h IDE own header file in the library header files*/
b.#include "school.h" /*School.h is a custom header files*/
So, if the #include <stdio.h> #include "stdio.h", written in the efficiency of compiler will be reduced, because at compile time, IDE will be the first in the current directory for #include "stdio.h", but can't find it, so will the catalog file system IDE for existence, header files, database compiled by but if they do not exist, the current *.c file directory and database file, will error.

Posted by Nat at January 02, 2017 - 6:45 PM

#include <ceshitou.h>
Change
#include "ceshitou.h"

VS the header file is added to the project to go inside the file, drag.
VC++ the file that contains the call in the include folder

Posted by Grace at January 05, 2017 - 7:19 PM

Personal habits, generally with the source file and directory, can also be placed separately, #include "\pathname\filename.h" can also be

Posted by William at January 08, 2017 - 7:27 PM