MMGames Introduction to C C Language Development Environment C language now Useful Apps Contact Us
MMGames

Automatic version identification

SpineViewer

It's easy to tell by looking at it.

Response Time Checker

I can leave my computer on and do it.

Mouse cleaning time

I can leave my computer on and do it.

Mouse cleaning time

C language learned by suffering
C language learned by suffering

Writing conventions

How to Write Functions
As explained in the previous section, the C language is a free format, but
That said, if everyone writes in different ways, the program becomes difficult to read.
For this reason, writing conventions are defined to some extent.

The first program I created crammed everything into one line.

source code
 int main(void) {return 0;}

Needless to say, this writing style is a difficult program to read and misbehave.
Functions are generally better written as follows

source code
 int main(void)
{
    return 0;
}

This way of writing makes it easier to see where the function begins and ends.
indent
Let's look again at the previous program.

source code
 int main(void)
{
    return 0;
}

You will notice that the return statement is shifted to the right.
This is called indentation, a characteristic writing style of the C language.

Keywords.
Indentation]

A method of writing by shifting to the right in order to express hierarchy.


Indentation is used to represent hierarchical structure.
In C, it is customary to slightly shift to the right any statement within a {}.

In this case, it is customary to use the Tab key to shift the text to the right.
Use the tab key to shift instead of using space to create a gap.
Recently, however, the style of shifting with four one-byte spaces is also used quite often...

Note that if you are using a modern development environment or text editor, you should use the
{} is automatically indented as soon as it is typed.
If possible, it would be easier to use such an editor and have them automatically attach the text.

Take it easy.
The most important thing for programmers is to make things easy.
In any case, everything that can be done by a computer should be done by a computer.
Let the computer do the chores, and let humans work on more creative tasks.

Comment
If it's a simple program, you can tell what it's about right away if you look at it.
In a complex program, its contents are not apparent at first glance.
If you include an explanation in the program, it will make the program easier to read.

The C language has the ability to include an explanation in a program, which is called a comment.

Keywords.
[Comment

A description to be written in the program. It has no effect on the operation of the program.


In C, you can comment between them by sandwiching them with /* */.
This comment does not affect the execution of the program in any way.

source code
 int main(void)
{
    /* comment here */
    return 0;
}

In this way, the description can be embedded in the program.
Again, comments do not affect the behavior of the program in any way.

Comments can be written on multiple lines or on one line of the program.

source code
 int main(void)
{
    /*
    This whole thing is a big deal for the
    Comment.
    */
    return 0; /* here is also a comment */
}

There is no particular standardized practice for writing comments.
Some people write a lot of comments, while others write only a few.
However, not writing comments at all can be a problem in a large program.
In fact, it is common for people to forget the contents of programs they have written.

From now on, in the programs we explain on the site, we will make comments where necessary.
You, too, should add comments to the programs you write.


About this Site

The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or more complete than any book on the market.

Part 0: Program Overview
  1. What is the program?
Chapter 2: How to write a program
  1. Writing Rules
  2. Writing conventions
  3. Exercise 2
Chapter 3: Display on Screen
  1. String display
  2. newline character
  3. Exercise 3
Chapter 4: Numeric Display and Calculation
  1. Numeric Display
  2. Basic Calculations
  3. Type of value
  4. Exercise 4
Chapter 5: Numerical Memory and Calculation
  1. Memorize values
  2. Variable Type
  3. Type conversion
  4. Numeric justification
  5. Exercise 5
Chapter 6: Input from the keyboard
  1. Functions for input
  2. Fear of Input
  3. Exercise 6
Chapter 9: Repetition with a fixed number of times
  1. Sentences that repeat themselves
  2. Loop Operation Mechanism
  3. Exercise 9
Chapter 10: Unknown number of repetitions
  1. Loop of unknown frequency
  2. input check
  3. Exercise 10
Chapter 13: Handling Multiple Variables at Once
  1. Multiple variables are handled together.
  2. How to use arrays
  3. Exercise 13
Chapter 19: Dynamic Arrays
  1. Create arrays at will
  2. Exercise 19
Chapter 20: Multiple Source Files
  1. Minimal division
  2. The Stone of Partition
  3. Exercise 20

Comment
COMMENT

Open the 💬 comment submission box