Home > Back-end >  A project about C language has run multiple source files
A project about C language has run multiple source files

Time:09-24

Of new beginner C, opposition have multiple source program, how to merge with confused
I use the compiler is VS2019, but today when testing a small program encountered this kind of circumstance

there are two source files, one is the source. The other one is c Max, Max c. C is a Max function
The following

Int Max (int a, int b)
{
If (a & gt; B)
return a;
The else
Return b;
}


then is the main function:
# include
# include
# include "Max. H"

Int main ()
{
Int a, b;
The scanf (" % d % d ", & amp; A, & amp; B);
Printf (" % d ", Max (a, score));
Printf (" % d ", Max (b, score));
}

Why I've been writing for Max. J c, but not to identify the main function of Max this function??

Excuse me why VS2019 if run multiple files to other operations? Not just run?

CodePudding user response:

There are two other way,

The first kind, the # include "Max. H" to # include "Max. C
"Second, to create a Max. H header file, and then put the Max function on the header file

You appear unable to identify the reason is you don't have the Max. H header file, only Max. C file,

CodePudding user response:

Make sure you have a Max. H file, and then put the Max function declarations in the header file, or don't use header files, on the main function and extern int Max (int a, int b);

CodePudding user response:

Append a Max. H file, the contents of the file to the
Int Max (int, int);

Or put the main. C # include "Max. H" removed, changed to extern int main (int, int);
  • Related