- ..clause 1..: Basic knowledge
- Memo
- ..clause 3..: Description type
- ..clause 4..: Basic knowledge(example solution)
- Memo(example solution)
- ..clause 6..: Description type(example solution)
[ 1-1 ]
What is chiefly called the file that describes the declaration?
Example solution
[ 1-2 ]
What is called the file where an actual program is described?
Example solution
[ 2-1 ]
void InputPeople(People *data) { Printf ("Name"); scanf("%s",data->name); Printf ("Age"); scanf("%d",&data->age); Printf ("Sex (one-..man.. two-woman)"); scanf("%d",&data->sex); printf("\n"); } void ShowPeople(People data) { char sex[16]; Printf ("Name: %s\n" data.name); Printf ("Age: %d\n" data.age); Strcpy (sex "Man"); } else { Strcpy (sex "Woman"); } Printf ("Sex: %s\n" sex); printf("\n"); }
Bring this program together in the header file and the source file.
Example solution
[ 3-1 ]
To operate even if all functions are described in one source file
Describe the reason purposely divided concisely.
[ 1-1 ]
Header file
Problem
[ 1-2 ]
Source file
Problem
[ 2-1 ]
/* People.h */ #ifndef __PEOPLE_H__ #define FONT> __PEOPLE_H__ #include <stdio.h> #include <string.h> typedef struct { char name[256]; int age; int sex; } People; /* */ that inputs individual data Extern void InputPeople(People *data); /* */ that displays individual data Extern void ShowPeople(People data); #endif
- There are various methods in division./* People.c */ #include "People.h" void InputPeople(People *data) { /* Omit contents because it is the same */. } void ShowPeople(People data) { /* Omit contents because it is the same */. }
Though all # include might be done by the source file
One in the header file regards the author. as can save time
Extern might not be put up to the prototype declaration of the function.
Though it follows the rule of the team when developing in the team
The rule doesn't suit me and even if it is old-fashioned, it ..(..
It is top priority to attempt the union of the forms. )
Keeping deciding the method by yourself and using it might be good for the individual development.
Problem
[ 3-1 ]
The prospect of the program improves by dividing.
Because it becomes easy to recycle and to develop the large number of people.