A do-nothing program.
Structures in C
Now, we're going to create your first program in C.
However, it's impossible to create a program with various functions from the beginning,
We'll start by creating a program that does nothing – a do-nothing program.
By the way, what kind of knowledge is needed to write C programs?
Whatever you build, you can't build it without knowing its structure.
To build a bookshelf, you need to know its structure, and the same is true in C.
So, what exactly is the structure of a C struct?
When making a machine, it's made by combining various parts.
Similarly, in programming, you combine components.This component is referred to as the function.
In essence, C programs are built from collections of functions.
The key thing to note here is not the order of the functions, but rather a collection of functions.
When we talk about ordering, it implies having an order.
However, when it comes to a gathering, there's no order to it.
C functions, with a few exceptions, have no concept of order.
The structure of a C language program is one composed of various functions bundled together.
Each function can be used in any order.
However, it's impossible to create a program with various functions from the beginning,
We'll start by creating a program that does nothing – a do-nothing program.
By the way, what kind of knowledge is needed to write C programs?
Whatever you build, you can't build it without knowing its structure.
To build a bookshelf, you need to know its structure, and the same is true in C.
So, what exactly is the structure of a C struct?
When making a machine, it's made by combining various parts.
Similarly, in programming, you combine components.This component is referred to as the function.
In essence, C programs are built from collections of functions.
The Structure of a C Program
C programs are built by collections of functions.
The key thing to note here is not the order of the functions, but rather a collection of functions.
When we talk about ordering, it implies having an order.
However, when it comes to a gathering, there's no order to it.
C functions, with a few exceptions, have no concept of order.
The structure of a C language program is one composed of various functions bundled together.
Each function can be used in any order.
How to create functions
It has become clear that the structure of a C language program is a collection of functions.
Then, the next issue that naturally arises is the structure of the function.
C functions have a very clear structure.The following is the structure of a C function.
Return type refers to the type of numerical value used when a function returns a result.
Just for now, please remember the type called int.
int stands for integer.
Function name literally means the name of a function.
There are certain rules for naming like this.
Reserved words are keywords used in the C language.
However, the number of these keywords is small, so it's not something to worry too much about.
If the previous conditions are met, any name will do.
For this time, let's try using the name main.
An argument is the type of value passed to a function.
A function can calculate a result based on the given number.
However, as mentioned earlier, the goal of this exercise is to create a program that does nothing.
There's no need to pass information to a program that does nothing.
Therefore, we will use void to represent the absence of information.
Processing is processing, as the name suggests.
As I mentioned earlier, the goal of this exercise is to create a program that does nothing.
This time, the only necessary task is to terminate the function B.
To exit a function, use the `return` statement.
Furthermore, the return statement has the functionality to return a numerical result.
Since this is a program that doesn't do anything this time, I'll just set it to 0 for now.
As such, the following function was completed.
Furthermore, I will explain the { } and ; later.
Then, the next issue that naturally arises is the structure of the function.
C functions have a very clear structure.The following is the structure of a C function.
Function Structure
typename functionName(arguments) { processing }
Return type refers to the type of numerical value used when a function returns a result.
Just for now, please remember the type called int.
int stands for integer.
Function name literally means the name of a function.
There are certain rules for naming like this.
Naming conventions
1. Half-width alphabetic characters, half-width numerals, and half-width underscores (_) can be used. 2. The first character cannot be a numeral. 3. Predefined reserved words cannot be used.
Reserved words are keywords used in the C language.
However, the number of these keywords is small, so it's not something to worry too much about.
If the previous conditions are met, any name will do.
For this time, let's try using the name main.
Reserved identifier
In C, besides reserved words, predefined identifiers cannot be used as names either. Predefined identifiers are names used internally; names consisting of an underscore followed by uppercase letters cannot be used, nor can names that are standard in the C language.
An argument is the type of value passed to a function.
A function can calculate a result based on the given number.
However, as mentioned earlier, the goal of this exercise is to create a program that does nothing.
There's no need to pass information to a program that does nothing.
Therefore, we will use void to represent the absence of information.
Processing is processing, as the name suggests.
As I mentioned earlier, the goal of this exercise is to create a program that does nothing.
This time, the only necessary task is to terminate the function B.
To exit a function, use the `return` statement.
Furthermore, the return statement has the functionality to return a numerical result.
Since this is a program that doesn't do anything this time, I'll just set it to 0 for now.
As such, the following function was completed.
Source code
int main(void) {return 0;}
Furthermore, I will explain the { } and ; later.
The main function is special.
Now, let's dive right in and try some programming using the completed function.
But before that, there's one more thing you need to know.
In section 1, we explained that functions have no order.
However, this creates one problem.
First, I'm unsure which function to start with.
In C, this problem is solved in a very straightforward way.
In the C language, it is specified that a function named main is the first to execute.
If there were no main function anywhere within the program,
The program won't work because the first function is gone.
Conversely, if you have a main function, a C program can run.
The function I just created is named main, so...
With this function, we can run the program.
But before that, there's one more thing you need to know.
In section 1, we explained that functions have no order.
However, this creates one problem.
First, I'm unsure which function to start with.
In C, this problem is solved in a very straightforward way.
In the C language, it is specified that a function named main is the first to execute.
Meaning of the main function
C programs are composed of a collection of functions. In C, the main function is the first to execute.
If there were no main function anywhere within the program,
The program won't work because the first function is gone.
Conversely, if you have a main function, a C program can run.
The function I just created is named main, so...
With this function, we can run the program.
Run the program.
Let's run the program now.
This is the do-nothing program I've created this time.
Please type in this program according to the compiler's explanation.
However, please do not copy and paste text from the browser.
Please type using the keyboard to get used to entering programs.
If you don't already have a compiler, please download it from here.
Learning C Development Environment
Once you've entered it, please run it right away.
The results of this program are as follows:
It looks like nothing is showing.Congratulations!
The result was exactly as intended: a program that does nothing.
In many environments, various texts will be displayed.
Please disregard them as they are not related to the program's operation.
This is the do-nothing program I've created this time.
Source code
int main(void) {return 0;}
Please type in this program according to the compiler's explanation.
However, please do not copy and paste text from the browser.
Please type using the keyboard to get used to entering programs.
If you don't already have a compiler, please download it from here.
Learning C Development Environment
Once you've entered it, please run it right away.
The results of this program are as follows:
Results
It looks like nothing is showing.Congratulations!
The result was exactly as intended: a program that does nothing.
In many environments, various texts will be displayed.
Please disregard them as they are not related to the program's operation.
About This Site
Learning C language through suffering (Kushi C) isThis is the definitive introduction to the C language.
It systematically explains the basic functions of the C language.
The quality is equal to or higher than commercially available books.




