Words and symbols
Reserved words
The basic keywords in C language are as follows:
Some compilers may define additional reserved words as well.
In addition, C++ compilers also define C++ keywords.
Often, they're words we use regularly, so we understand them without even realizing it.
I think you'll quickly notice it's a compiler error if you happen to use it.
However, reserved words can also be used as macro names.
It's best to avoid it to prevent confusion.
Actually, 'main' is not a reserved word, so you can use it for variable names without any issues.
It would be better not to use it because it feels off.
C keywords
auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
Some compilers may define additional reserved words as well.
In addition, C++ compilers also define C++ keywords.
Often, they're words we use regularly, so we understand them without even realizing it.
I think you'll quickly notice it's a compiler error if you happen to use it.
However, reserved words can also be used as macro names.
It's best to avoid it to prevent confusion.
Actually, 'main' is not a reserved word, so you can use it for variable names without any issues.
It would be better not to use it because it feels off.
Output format specifiers
This is documentation regarding the format and specifiers for output conversion specifiers.
It's commonly used with functions like printf.
Specify these connected.Non-type specifiers can be omitted.
Typically, only the length is specified for alignment.
Note that the point between length and precision is a decimal point.It's not a comma.
Incidentally, some systems also maintain size information relating to precision and type.
This is for far/near pointers, and it's clearly outdated, so I won't deal with it.
Let L represent the length value and P represent the accuracy value.
※0 is technically optional, but we include it here for the sake of length and accuracy.
The correct format specifier to use for displaying doubles is %f.
Originally, %lf did not exist, but now %lf can be used as well.
It's commonly used with functions like printf.
Output format specifiers
% option length.precision type
Specify these connected.Non-type specifiers can be omitted.
Typically, only the length is specified for alignment.
Note that the point between length and precision is a decimal point.It's not a comma.
Incidentally, some systems also maintain size information relating to precision and type.
This is for far/near pointers, and it's clearly outdated, so I won't deal with it.
Options一覧
| symbol | 効果 |
|---|---|
| - | 左詰めでTable示 |
| + | 右詰めでTable示 |
| # | 0、or小数点の抑制を行わない。 |
長さと精度のFormat
| symbol | 効果 |
|---|---|
| L | 最低でもL桁で出力する。余WhiteはSpaceで埋める。 |
| 0L | 最低でもL桁で出力する。余Whiteは0で埋める。 |
| L.P | 全体を最低でもL桁、小数点以下をP桁で出力。 |
| L.0 | 全体を最低でもL桁、小数点以下は出力しない。 |
※0 is technically optional, but we include it here for the sake of length and accuracy.
型一覧
| symbol | Meaning |
|---|---|
| d,i | Integerのdecimal number。 |
| o | Integerのoctal符号None。 |
| x,X | Integerの16進符号None。x は小Character、X は大Characterで。 |
| u | Integerdecimal number符号None。 |
| f | Real Number。 |
| e,E | Real Numberの指数Format。e は小Character、E は大Character。 |
| g,G | Real Numberのサイズに応じて、normal出力か指数Formatが選択される。 |
| c | 1Character。 |
| s | String。ヌルCharacterまで出力。 |
| p | Pointerのaddressとして出力。16進大Character。 |
| n | これまでに書き出されたnumber of charactersの出力。型変換をしない。 |
| % | Character % の出力。型変換をしない。 |
The correct format specifier to use for displaying doubles is %f.
Originally, %lf did not exist, but now %lf can be used as well.
Input Conversion Specifiers
This is documentation on the format and specifiers for input conversion specifiers.
It is primarily used with functions like scanf.
Specify these connected.Non-type specifiers can be omitted.
Often, to specify input limitations, one will typically specify length alone.
Incidentally, some systems hold information about the size of pointers regarding the length and size.
This is for far/near pointers, and it's clearly outdated, so I won't deal with it.
If an asterisk is present, the data is skipped.(Not assigned to a variable)
It's used to skip unnecessary data when loading file data, for example.
When a length is specified, it reads a number (or string) with that many digits.
It is used to prevent exceeding digit length limits or string buffer boundaries.
Input conversion specifiers enforce stricter type checking because they perform assignments.
There's no double type in the list above, but...
This is specified in conjunction with the size specifier l.
It is primarily used with functions like scanf.
Input Conversion Specifiers
% * Length Size Type
Specify these connected.Non-type specifiers can be omitted.
Often, to specify input limitations, one will typically specify length alone.
Incidentally, some systems hold information about the size of pointers regarding the length and size.
This is for far/near pointers, and it's clearly outdated, so I won't deal with it.
If an asterisk is present, the data is skipped.(Not assigned to a variable)
It's used to skip unnecessary data when loading file data, for example.
When a length is specified, it reads a number (or string) with that many digits.
It is used to prevent exceeding digit length limits or string buffer boundaries.
サイズ一覧
| symbol | 効果 |
|---|---|
| h | 読み込んだデータをshort型に変換する。 |
| l | 読み込んだデータを型の指定に合わせて、long型かdouble型に変換する。 |
| L | 読み込んだデータをlong double型に変換する。 |
型一覧
| symbol | Meaning |
|---|---|
| d | int型のdecimal number。 |
| o | int型のoctal。 |
| x | int型のhexadecimal。 |
| i | int型。Numberはデータにあわせて決定。 |
| u | unsigned int型の符号Nonedecimal number。 |
| f | float型 |
| e,E | float型の指数Format。e は小Character、E は大Character。 |
| g,G | normalFormatか指数Format。 |
| c | char型のCharacter。 |
| s | Spaceを含まないchar型のString。 |
| p | PointerのValue。 |
| n | これまでに読み込まれたnumber of charactersをAssignment。データを読み込まない。 |
| % | 何もしない。無Meaningな指定。 |
Input conversion specifiers enforce stricter type checking because they perform assignments.
There's no double type in the list above, but...
This is specified in conjunction with the size specifier l.
Operators and Precedence
The operator precedence in C is very well designed,
In typical usage, it's not necessary to explicitly include ().
It usually works if you write it according to the formula.
When you're unsure about your priorities, it's better to compare them by looking at this table than...
It's easy and reliable to () attach.
C Language Operators and Precedence
The higher up, the higher the priority.
The symbols in each delimited section will have the same precedence.
There are no specific rules for the name, so I used a commonly used designation.
Below, you'll find an explanation of some operators.
The reference operator is an operator that switches a pointer variable to normal variable mode.
The asterisk used when declaring pointer variables has no grammatical relevance.
The array subscript operator refers to the brackets [] that are attached to an array.
That function adds the byte size of a variable to an address.
Note that the brackets used when declaring an array have no grammatical relationship.
The conditional operator is a simplified way to create conditional expressions, and is used as follows:
If the condition is true, expression 1 is executed, and if it's false, expression 2 is executed.
And the result is assigned to a variable, but it can be used without specifying a variable.
Some people, including myself, prefer to use it because it allows for simpler conditional judgments than if statements.
Furthermore, this operator uses three operands, which is why it's also known as the ternary operator.
The sequential operator is a way to combine two expressions into one.
In this example, i = 3 is calculated first, and then i + 2 is calculated.
Ultimately, j will be assigned the value of 5.
However, this operator doesn't really have any practical use.
In typical usage, it's not necessary to explicitly include ().
It usually works if you write it according to the formula.
When you're unsure about your priorities, it's better to compare them by looking at this table than...
It's easy and reliable to () attach.
C Language Operators and Precedence
The higher up, the higher the priority.
The symbols in each delimited section will have the same precedence.
型一覧
| name | symbol | Function | 結合規則 | 項数 |
|---|---|---|---|---|
| array添字 | [] | arrayのElement numberの指定 | 左From右 | 単項 |
| functionCall | () | functionを呼び出す | 左From右 | 単項 |
| 要素選択 | . | structの要素を選択 | 左From右 | 単項 |
|
|
||||
| アロー | -> | structPointerの要素を選択 | 左From右 | 単項 |
| 後置increment | ++ | VariableのValueを1増やす | None | 単項 |
| 後置デクリメント | -- | VariableのValueを1減らす | None | 単項 |
| 前置increment | ++ | VariableのValueを1増やす | None | 単項 |
| 前置デクリメント | -- | VariableのValueを1減らす | None | 単項 |
| 参照 | * | PointerのさすVariableにアクセス | None | 単項 |
| address | & | Variableのaddressにアクセス | None | 単項 |
| 単項プラス | + | 正のValueにする | None | 単項 |
| 単項マイナス | - | 負のValueにする | None | 単項 |
| 論理否定 | ! | 真と偽の状態をInversion | None | 単項 |
| サイズオブ | sizeof | Variableやarrayや型のサイズを取得 | None | 単項 |
| キャスト | (型) | 指定の型に強制変換 | 右From左 | 単項 |
|
|
||||
| 乗算 | * | 掛け算 | 左From右 | 2項 |
| 除算 | / | 割り算 | 左From | 2項 |
| 剰余 | % | 余り | 左From右 | 2項 |
|
|
||||
| 加算 | + | 足し算 | 左From右 | 2項 |
| 減算 | - | 引き算 | 左From右 | 2項 |
|
|
||||
| 左シフト | << | VariableのValueを1ビット左にずらす(double) | 左From右 | 単項 |
| 右シフト | >> | VariableのValueを1ビット右にずらす(半minute) | 左From右 | 単項 |
|
|
||||
| 小なり | < | 左側のValueが右より小さいHourに真 | 左From右 | 2項 |
| 大なり | > | 左側のValueが右より大きいHourに真 | 左From右 | 2項 |
| 以下 | <= | 左側のValueが右以下のHourに真 | 左From右 | 2項 |
| 以上 | >= | 左側のValueが右以上のHourに真 | 左From右 | 2項 |
|
|
||||
| 等価 | == | 左と右のValueが等しいHour真 | 左From右 | 2項 |
| 不等価 | != | 左と右のValueが異なるHour真 | 左From右 | 2項 |
|
|
||||
| ビットAND | & | ANDを取る | 左From右 | 2項 |
|
|
||||
| ビットExclusive OR | ^ | Exclusive ORを取る | 左From右 | 2項 |
|
|
||||
| ビットOR | | | ORを取る | 左From右 | 2項 |
|
|
||||
| 論理AND | && | 左と右の両方が真のHourに真 | 左From右 | 2項 |
|
|
||||
| 論理OR | || | 左と右のどちらかが真のHourに真 | 左From右 | 2項 |
|
|
||||
| 条件 | ?と: | 真のHourは前式を、偽のHourは後式をAssignment | 右From左 | 3項 |
|
|
||||
| Assignment | = | 左のVariableに右の式のValueをAssignment | 右From左 | 2項 |
| Assignment乗算 | *= | 左のVariableに右の式とのValueの掛け算をAssignment | 右From左 | 2項 |
| Assignment除算 | /= | 左のVariableに右の式とのValueの割り算をAssignment | 右From左 | 2項 |
| Assignment剰余 | %= | 左のVariableに右の式とのValueの余りをAssignment | 右From左 | 2項 |
| Assignment加算 | += | 左のVariableに右の式とのValueを足し算をAssignment | 右From左 | 2項 |
| Assignment減算 | -= | 左のVariableに右の式とのValueを引き算をAssignment | 右From左 | 2項 |
| 左シフトAssignment | <<= | 左のVariableに右の式とのValueの左シフトをAssignment | 右From左 | 2項 |
| 右シフトAssignment | >>= | 左のVariableに右の式とのValueの右シフトをAssignment | 右From左 | 2項 |
| ビットANDAssignment | &= | 左のVariableに右の式とのValueのANDをAssignment | 右From左 | 2項 |
| ビットExclusive ORAssignment | ^= | 左のVariableに右の式とのValueのExclusive ORをAssignment | 右From左 | 2項 |
| ビットORAssignment | = | 左のVariableに右の式とのValueのORをAssignment | 右From左 | 2項 |
|
|
||||
| 順次 | , | 式を結合 | 左From右 | 2項 |
There are no specific rules for the name, so I used a commonly used designation.
Below, you'll find an explanation of some operators.
The reference operator is an operator that switches a pointer variable to normal variable mode.
The asterisk used when declaring pointer variables has no grammatical relevance.
The array subscript operator refers to the brackets [] that are attached to an array.
That function adds the byte size of a variable to an address.
Note that the brackets used when declaring an array have no grammatical relationship.
The conditional operator is a simplified way to create conditional expressions, and is used as follows:
Conditional operator
variable = (condition) ? expression1 : expression2;
If the condition is true, expression 1 is executed, and if it's false, expression 2 is executed.
And the result is assigned to a variable, but it can be used without specifying a variable.
Some people, including myself, prefer to use it because it allows for simpler conditional judgments than if statements.
Furthermore, this operator uses three operands, which is why it's also known as the ternary operator.
The sequential operator is a way to combine two expressions into one.
Sequential operator
j = (i = 3 , i + 2 );
In this example, i = 3 is calculated first, and then i + 2 is calculated.
Ultimately, j will be assigned the value of 5.
However, this operator doesn't really have any practical use.
Memory class specifier
C offers the following storage class specifiers.
However, it seems many of them are already obsolete.
However, it seems many of them are already obsolete.
Memory class specifier
auto
register
static
extern
typedef
register
static
extern
typedef
auto specifier
It means the variable is an automatic variable.
しかし、functionの内部ではautomatic的にautomaticVariableになるし、
It's a meaningless specifier because it results in an error outside of a function.
しかし、functionの内部ではautomatic的にautomaticVariableになるし、
It's a meaningless specifier because it results in an error outside of a function.
register specifier
It means that variable is frequently used.
昔はこのVariableをレジスタに割り当てることで、
処理の高速化を行っていましたが、
Compiler optimizations are prioritized nowadays.
現代では、マルチスレッドProgrammingで、
It can be used as a designation for a variable undergoing exclusive processing.
昔はこのVariableをレジスタに割り当てることで、
処理の高速化を行っていましたが、
Compiler optimizations are prioritized nowadays.
現代では、マルチスレッドProgrammingで、
It can be used as a designation for a variable undergoing exclusive processing.
static specifier
It means that variable will persist until the program ends.
Within a function, variable values are maintained within the function's scope.
Outside of a function, a variable is only accessible within the file where it is defined.
Within a function, variable values are maintained within the function's scope.
Outside of a function, a variable is only accessible within the file where it is defined.
`extern` specifier
It means that definitions, such as variables, are done in other source files.
It is used to declare common variables within a header file.
It is used to declare common variables within a header file.
`typedef` specifier
I declare a new type.
It allows for easy type declarations and compiler checking.
Note: This is not originally related to the Memory class, but is included here for grammatical convenience.
It allows for easy type declarations and compiler checking.
Note: This is not originally related to the Memory class, but is included here for grammatical convenience.
escape character
It's used for manipulating string display and other operations, even though it can't be displayed on the screen.
Line breaks are well-known, but there are also others like these.
These are commonly used.
The form feed character (\f) can only be used for printer output and is not commonly used.
\r is a line ending in Mac, and now it's a line ending on other operating systems as well.
Escape characters require two or more characters in their notation.
It's a display issue, but internally it's treated as a single character.
Line breaks are well-known, but there are also others like these.
escape character
| escape character | hexadecimal | Function |
|---|---|---|
| \a | 0x07 | ビープ音を鳴らす |
| \b | 0x08 | カーソル位置を1つ後ろにずらす |
| \t | 0x09 | カーソル位置を次のタブ位置に移動する |
| \n | 0x0A | カーソル位置を次の行に移動(改行) |
| \f | 0x0C | 紙を排出する(Printerの場合のみ) |
| \r | 0x0D | カーソル位置を行の一番左に移動(Macでは改行) |
| \\ | 0x5C | \をTable示する |
| \' | 0x2C | 'をTable示する |
| \" | 0x22 | "をTable示する |
| \? | 0x3F | ?をTable示する |
| \digit | octalでsame | 対応するoctalのCharacter encodingをTable示 |
| \xdigit | digitとsame | 対応するhexadecimalのCharacter encodingをTable示 |
These are commonly used.
The form feed character (\f) can only be used for printer output and is not commonly used.
\r is a line ending in Mac, and now it's a line ending on other operating systems as well.
Escape characters require two or more characters in their notation.
It's a display issue, but internally it's treated as a single character.
Defined constants
In C, information about the compiler and debugger, among other things,
It's provided as a defined constant.
By using `__FILE__` and `__LINE__`, you can determine the file and line number at runtime.
We can pinpoint the line number where the error occurred.
It's very useful for dumping to log files or using in a simple debugger.
このFunctionが他のProgramming Languageにも欲しいよう...
These constants require the inclusion of `#define `.
Whether a `char` type is signed depends on the compiler.
Naturally, both are designed to ensure no impact on character storage.
It's provided as a defined constant.
デバッグ用Constant
| Constant | Meaning |
|---|---|
| __LINE__ | runされている行Number |
| __FILE__ | runされているSource file名 |
| __DATE__ | コンパイルされたDate |
| __TIME__ | コンパイルされたTime |
By using `__FILE__` and `__LINE__`, you can determine the file and line number at runtime.
We can pinpoint the line number where the error occurred.
It's very useful for dumping to log files or using in a simple debugger.
このFunctionが他のProgramming Languageにも欲しいよう...
Integer型サイズのDefined constants
| Constant | numericsのMeaning |
|---|---|
| CHAR_BIT | char型のビット単位のサイズ。 |
| CHAR_MAX | char型のmaximum value。 |
| CHAR_MIN | char型のminimum value。 |
| INT_MAX | int型のmaximum value。 |
| INT_MIN | int型のminimum value。 |
| LONG_MAX | long型のmaximum value。 |
| LONG_MIN | long型のminimum value。 |
| SCHAR_MAX | signed char型のmaximum value。 |
| SCHAR_MIN | signed char型のminimum value。 |
| SHART_MAX | short型のmaximum value。 |
| SHART_MIN | short型のminimum value。 |
| UCHAR_MAX | unsigned char型のmaximum value。 |
| UINT_MAX | unsigned int型のmaximum value。 |
| ULONG_MAX | unsigned long型のmaximum value。 |
| USHRT_MAX | unsigned short型のmaximum value。 |
Whether a `char` type is signed depends on the compiler.
Naturally, both are designed to ensure no impact on character storage.
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.




