Header: Do you really understand me? ? ?

When I was in the Linux class, I was asked a question by the teacher. What is the difference between <stdio.h> and "stdio.h"?

To be honest, when I heard this question, I thought to myself, isn’t it the same? After learning and using the C language for so long, it should be considered an ideal. . In fact, these details can also reflect how well you have mastered the basics. I heard that for interviews, big companies are more inclined to ask about these basic internal skills.
Insert picture description here

The difference between <stdio.h> and "stdio.h"

When the preprocessor finds the #include directive, it will look at the following file name and include the content of the file in the current file, that is, replace the #include directive in the source file, which is equivalent to inputting the entire content of the included file into the source The location of the file #include directive.

#include directive has two forms:

① #include <stdio.h>

② #include “mycoce.h”

The first type is <> tells the preprocessor to find files in the standard system directory, and the second type is "" tells the preprocessor to first search for files in the current directory (or other directories specified by the file name), and then search again Standard system catalog.

Self-written header file

A header file is written as follows, named ps.h, and the storage address is as follows:

#include <stdio.h>

  #define PR printf

Insert picture description here

Then when I write the program in the future, I only need to include #include "D:\PyCharm Community Edition 2020.2\ps.h" at the beginning

This way you can avoid #include <stdio.h>, because I have included it in another file. So for example, if I want to output "hhh succeeded" in the program, I can use PR to represent printf, as follows

#include "D:\PyCharm Community Edition 2020.2\ps.h"

int main()

{
    
    

    PR("hhh成功了");

    return 0;
}

Insert picture description here
Insert picture description here

This will succeed!

Guess you like

Origin blog.csdn.net/weixin_44093867/article/details/108904571