<> introduction

In a complex program ,c All the data types of language can not meet our needs , Often need to define their own data structure . There will be a problem here , When your code is not stored in a source file , And there is also the transmission of structure data between functions . So how to share the same structure in different source files ?
<> Different source files share the same structure

first , We may consider defining the same structure in different source files , however , Although the data types of structures are the same , The name is the same , But in the compiler compilation process , It's not the same data type , And report a mistake ( The data type you passed in does not match what you need ).
* Whether it's an integrated environment or gcc Compiler, his method is the same .
* First define a header file // Header file str.h #ifndef _STR_H_ //ifndef namely if no define The abbreviation is
// If there is no definition, execute the following code , definition // There's no need to redefine it ._STR_H_ This is yours // The header file name is capitalized and underlined . #define _STR_H_
typedef struct { char *ch; int length; } Str; #endif
2. This header file is introduced into each source file
#include "str.h"

* Because there is a judgment in the header file first , You don't have to worry about multiple structs generated at compile time .

©2020 ioDraw All rights reserved
Centralized processing (mean centering) The myth and truth of C Notes on language learning —— Pointer : Pointer and one dimensional array java properties Profile tool class Detailed explanation PHP Medium die,exit,returnC++ String And char* Mutual conversion 《 From machine learning to deep learning 》 note (2) Unsupervised learning python Medium gc Recovery mechanism PHP call shell command Mediating effect , What about regulatory effect and interaction ?Python Student information management system ( Lite )