Multi-file team development issues
Group cooperation is very important today, to enter the company will need to how to collaborate on the division of labor, for example, the software, someone to write a login, someone to implement a friend to add functionality, someone responsible for the circle of friends and so on, such a large-scale software development, many people write a program case, is not. There will be many problems. There is a common development of multiple files to solve such problems. We all work together to do each of the functions, and finally connect them. Achieve overall functionality.
Today saw a multi-file T team Development, here is said Zhang San only do the main () function, John Doe do function declaration. When Zhang San calculates the average of a score, it calls the average function written by John Doe.
The main () function of the Zhang San. c file.
#include <stdio>int main () { int score1=12; int score2=5; int C=average (score1,score2); printf ("Average score is%d\n", c); return 0;}
John Doe. C Program Call function is
int average (int a,int b) { return (A+B)/2;}
John Doe. h file
int average (int a,int b);
Zhang San when using John Doe. h files
#include <stdio> #include "John Doe. H"//Do not write int average (int a, int b); int main () { int score1=12; int score2=5; int C=average (score1,score2); printf ("Average score is%d\n", c); return 0;}
To make the average in the main () function error-prone, you have to connect the three. C and John Doe. C together.
The teacher's method is: Zhang San call John Doe function, also have to Zhang San themselves again to write average function declaration in their own # # #, so if the program a lot of statements, feel every time the statement is very troublesome. Because Zhang San himself had to find John Doe to declare the function. Let John Doe himself wrote a John Doe. H, to install his own statement. In Zhang San inside #include<stdio.h> not write John Doe statement, changed to include "John Doe. H"
My own idea: You can write the John Doe. h file directly to the declaration function, or directly below the #include<stdio.h> write the # include "John Doe. C" file.
Why write three files, the program runs from up to down. Put the John Doe. c file in John Doe. H, it's OK. Right, the function was declared when it was executed to main (). You don't have to write that.
John Doe. H
int average (int a,int b);
Dark Horse Programmer C Language Multi-file for team development issues