MMGameslogo  MMGames
TwitterSharebutton  FacebookSharebutton   
learn through sufferingC Language
learn through sufferingC Language

Rules of Writing

token
Japanese text consists of elements like characters, words, sentences, and paragraphs.
It can be broken down into its various constituent elements.
C programs can be disassembled in the same way.

When grammatically decomposing a C language program, the smallest unit is tokens.
In short, a token is essentially a word.For example, the first program we created was...

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

However, breaking this down token by token yields the following.

Tokenization
int
main
(
void
)
{
return
0
;
}

The reason tokens are called the smallest unit is because they cannot be further broken down without changing their meaning.
たとえば、return を、ret urn にminute解すると、Errorが表示され、動作出来なくなります。
free-form
C is a free-format language, meaning it has a flexible format.
Since there are few restrictions on how to write the program, you can write it in a very free style.

キーワード
【free-form】

The programming guidelines are flexible, allowing for a lot of freedom in how you write code.


There's only one clear rule when it comes to writing C programs.
It means you shouldn't write by connecting tokens.
For example, you shouldn't write your initial program like this.

Token concatenation
intmain(void) {return 0;}

In this example, the problem is that int and main are stuck together.

However, there are exceptions, as can be seen from the first program we created.
That means the symbol can be written as a continuous line.
In the first program I created, I wrote things like () {} together.

"It's because the symbols are predetermined single characters, allowing them to be distinguished even when connected."
"In the case of intmain, it just looks like a token named intmain."
"However, with main(void), it's immediately obvious that it's main, followed by parentheses, and then void."

"In C language programs, the writing rules are only these."
"As long as you write them without linking non-symbol tokens, it will recognize them."
Actually, even this program can be compiled without any issues.

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

Other rules
C has its own rules for writing code, separate from the guidelines previously mentioned.
First, C is case-sensitive.
For example, in C, main, MAIN, and maIN are interpreted as completely different tokens.
Therefore, please pay attention to the case (uppercase and lowercase) when entering the program.

In C, a semicolon (;) must be written at the end of each statement.
In the previous program, a semicolon was attached to the end of the return statement.
Please be careful not to forget this, or you'll get an error.

One important note: C does not recognize full-width characters.
You can use full-width characters for strings displayed on the screen, but...
Please enter everything in the program using only full-width characters.

The Full-Width Space Trap
プログラムを記述するときにやってしまう間違いがfull-pitch characterスペースis.
full-pitch characterスペースもfull-pitch character文字なので、Compilerはこれを間違いとします。
full-pitch characterスペースが表示されないテキストエディタを使用していると、
どこに間違いがあるのかがわからなくなってしまいます。



About This Site

Learning C language through suffering (Kushi C) is
This 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.

Part 0: Program Overview
  1. What is a program?
Chapter 3: Displaying on the Screen
  1. String Display
  2. newline character
  3. Practice Problem 3
Chapter 4: Displaying and Calculating Numbers
  1. Display of numbers
  2. Basic calculations
  3. Numeric types
  4. Practice Problem 4
Chapter 6: Input from the Keyboard
  1. input function
  2. The fear of input
  3. Practice Problem 6
Chapter 9: Repeating a Fixed Number of Times
  1. Iterative sentence
  2. How Loops Work
  3. Practice Problem 9
Chapter 10: Repeating Without Knowing the Number of Times
  1. Unspecified loop
  2. Input validation
  3. Practice Problem 10
Chapter 13: Handling Multiple Variables at Once
  1. Handling multiple variables collectively.
  2. Arrays
  3. Practice Problem 13
Chapter 19: Dynamic Arrays
  1. Create arrays freely.
  2. Practice Problem 19