Home > Back-end >  C language reference source files containing function many times
C language reference source files containing function many times

Time:12-12

I defined the three source files, one of the stored data, another main function, the third to modify the data. Due to the second three are need to use the first function, and cited the first function, but due to the function definition of the first function, and the definition of a global variable, result in an error redefinition of XXX.

The following is the first code
# include
Void cal_database (void)
{
Static int total_num=0;

Struct record
{
Int number;
Char name [10].
Int enter_year;
Char indentity_in_school [100].
Char apartment [20].
Char area [20].
Char type [1000].
} num [101].

for(int i=1; i<100; I++)
{
If (num [I]. Name [0]!='\ 0')
Total_num + +;
The else
break;
}
}

Then all three of the second include "database. CPP"

Error:

CodePudding user response:

Create a database. H file, inside the following
 
# # ifndef _FILE_DATABASE_H_
# ifdefine _FILE_DATABASE_H_

Void cal_database (void);

# endif


Then the second three are include database. H

CodePudding user response:

The building Lord what you use the development environment, has not the concept of the project or solution or Makefile?
Is don't need to include the source code files,
  • Related