- ..clause 1..: Structure of C language
- ..clause 2..: How to make function
- ..clause 3..: The main function specially :.
- ..clause 4..: Operate the program.
Hereafter, make the first program by C language.
However, making the program with various functions from the start : because it is impossible.
First of all, start from making the program that doesn't do anything in which the function is not provided either.
By the way, what knowledge is necessary to make the program of C language?
If it doesn't know the structure no matter what it makes it, it is not likely to be able to make it.
Even C language of this is similar though it is necessary to know the structure of the bookshelf to make the bookshelf.
Then, what on earth structure is the structure of C language?
Combine and make various parts when you make the machine.
Similarly, the programming combines parts. This part is called a function.
In a word, the program of C language gathers functions and is made.
Noting it here is a point of not the row of the function but the function of gathering.
[ C language program structure ]
The program of C language gathers functions and is made.
In the function of C language, one exception is excluded, and there is no concept of order at all.
The program structure of C language : in the structure that various functions become the person hardening.
Each function can be used in favorite the order.
I see ..sets of functions it... the program structure of C language
Then, it is a structure of the function naturally that becoming a problem next.
The function of C language has a very clear structure. The following are the structures of the function of C language.
[ Structure of function ]The type name is a kind of of the numerical value used when the function returns the numerical result.
Type name function name (argument)Processing
The function name is literally a name of the function.
In how to give this name, there is regulations like the under.
[ Rule at the previous state of person ]The reserved word is a key word used in C language.
1, normal-width alphabet, normal-width figure, and normal-width _ (under bar) can be used.
The first two characters, the figure cannot be used.
3 and the reserved word decided beforehand cannot be used.
Though it doesn't care about any name if it meets the requirement ahead
Will use the name of main (main) for the time being this time.
[ Reserved identifier ]The argument is a kind of of the numerical value passed to the function.
Another and the identifier of the reserved word that has been reserved cannot be used by C language as a name.
The reserved identifier is a name used internally.
The name that the capital letter leads to under a bar cannot be used.
The name used by C language standard cannot be used.
Processing is processing as shown in the name.
Any this purpose is to make the program not done as described in the start
This time, the processing that should be only done includes processing that ends the function.
Use return (return) sentence to end the function.
Though the function to return the numerical value of the numerical result is provided in the return sentence
It makes it to 0 for the time being because it is a program that doesn't do anything this time.
As mentioned above was done, and the following functions were completed.
It has not explained yet. [Ni], it will explain later.int main(void) {return 0;}
Well, want to do the programming by immediately using the completed function, and
However, only another one might have to be known ahead of that.
In clause 1, it explained that order did not exist in the function.
However, having embarrassed it by one happens with this.
It hesitates from which function to only have to mark down the first first.
In C language, this problem is solved by a very simple method.
In C language, the first function named main has been decided operation at the beginning.
When there is no main function in the program anywhere
[ Meaning of main function ]
In C language, at the beginning, the first main function operates.
Because the name is main in the function made ahead
If this function exists, the program can be operated.
Then, let's have them immediately execute the program.
It is a program that doesn't do anything that this made this time.
Drive this program according to the explanation of the compiler.int main(void) {return 0;}
Operate it immediately when you drive it.
The execution result of this program becomes as follows.
Nothing seems to be displayed. It resulted the same as this target.