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
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.
Output format specifiers
"% option length.precision type"
Specify these connections.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 handle it."
オプション一覧
symbol
効果
-
左詰めで表示
+
右詰めで表示
#
0、or小数点の抑制を行わない。
長さと精度の書式
symbol
効果
L
最低でもL桁で出力する。余白はスペースで埋める。
0L
最低でもL桁で出力する。余白は0で埋める。
L.P
全体を最低でもL桁、小数点以下をP桁で出力。
L.0
全体を最低でもL桁、小数点以下は出力しない。
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.
型一覧
symbol
意味
d,i
整数のdecimal number。
o
整数のoctal符号None。
x,X
整数の16進符号None。x は小文字、X は大文字で。
u
整数decimal number符号None。
f
実数。
e,E
実数の指数Format。e は小文字、E は大文字。
g,G
実数のサイズに応じて、normal出力か指数Formatが選択される。
c
1文字。
s
文字列。ヌル文字まで出力。
p
Pointerのaddressとして出力。16進大文字。
n
これまでに書き出されたnumber of charactersの出力。型変換をしない。
%
文字 % の出力。型変換をしない。
"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 specifier
This is documentation on the format and specifiers for input conversion specifiers.
It is primarily used with functions like scanf.
Input conversion specifier
"% * Length Size Type"
Specify these connections.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 handle 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
意味
d
int型のdecimal number。
o
int型のoctal。
x
int型のhexadecimal。
i
int型。進数はデータにあわせて決定。
u
unsigned int型の符号Nonedecimal number。
f
float型
e,E
float型の指数Format。e は小文字、E は大文字。
g,G
normalFormatか指数Format。
c
char型の文字。
s
Spaceを含まないchar型の文字列。
p
Pointerの値。
n
これまでに読み込まれたnumber of charactersをAssignment。データを読み込まない。
%
何もしない。無意味な指定。
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.
型一覧
名前
symbol
機能
結合規則
項数
array添字
[]
arrayの要素番号の指定
左から右
単項
function呼び出し
()
functionを呼び出す
左から右
単項
要素選択
.
structの要素を選択
左から右
単項
-----
アロー
->
structPointerの要素を選択
左から右
単項
後置increment
++
variableの値を1増やす
None
単項
後置デクリメント
--
variableの値を1減らす
None
単項
前置increment
++
variableの値を1増やす
None
単項
前置デクリメント
--
variableの値を1減らす
None
単項
参照
*
Pointerのさすvariableにアクセス
None
単項
address
&
variableのaddressにアクセス
None
単項
単項プラス
+
正の値にする
None
単項
単項マイナス
-
負の値にする
None
単項
論理否定
!
真と偽の状態をInversion
None
単項
サイズオブ
sizeof
variableやarrayや型のサイズを取得
None
単項
キャスト
(型)
指定の型に強制変換
右から左
単項
-----
乗算
*
掛け算
左から右
2項
除算
/
割り算
左から
2項
剰余
%
余り
左から右
2項
-----
加算
+
足し算
左から右
2項
減算
-
引き算
左から右
2項
-----
左シフト
<<
variableの値を1ビット左にずらす(double)
左から右
単項
右シフト
>>
variableの値を1ビット右にずらす(半minute)
左から右
単項
-----
小なり
<
左側の値が右より小さいHourに真
左から右
2項
大なり
>
左側の値が右より大きいHourに真
左から右
2項
以下
<=
左側の値が右以下のHourに真
左から右
2項
以上
>=
左側の値が右以上のHourに真
左から右
2項
-----
等価
==
左と右の値が等しいHour真
左から右
2項
不等価
!=
左と右の値が異なるHour真
左から右
2項
-----
ビットAND
&
ANDを取る
左から右
2項
-----
ビットExclusive OR
^
Exclusive ORを取る
左から右
2項
-----
ビットOR
|
ORを取る
左から右
2項
-----
論理AND
&&
左と右の両方が真のHourに真
左から右
2項
-----
論理OR
||
左と右のどちらかが真のHourに真
左から右
2項
-----
条件
?と:
真のHourは前式を、偽のHourは後式をAssignment
右から左
3項
-----
Assignment
=
左のvariableに右の式の値をAssignment
右から左
2項
Assignment乗算
*=
左のvariableに右の式との値の掛け算をAssignment
右から左
2項
Assignment除算
/=
左のvariableに右の式との値の割り算をAssignment
右から左
2項
Assignment剰余
%=
左のvariableに右の式との値の余りをAssignment
右から左
2項
Assignment加算
+=
左のvariableに右の式との値を足し算をAssignment
右から左
2項
Assignment減算
-=
左のvariableに右の式との値を引き算をAssignment
右から左
2項
左シフトAssignment
<<=
左のvariableに右の式との値の左シフトをAssignment
右から左
2項
右シフトAssignment
>>=
左のvariableに右の式との値の右シフトをAssignment
右から左
2項
ビットANDAssignment
&=
左のvariableに右の式との値のANDをAssignment
右から左
2項
ビットExclusive ORAssignment
^=
左のvariableに右の式との値のExclusive ORをAssignment
右から左
2項
ビットORAssignment
=
左のvariableに右の式との値のORをAssignment
右から左
2項
-----
順次
,
式を結合
左から右
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:
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.
Memory class specifier
auto 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."
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.
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.
`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.
`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."
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.
escape character
escape character
hexadecimal
機能
\a
0x07
ビープ音を鳴らす
\b
0x08
カーソル位置を1つ後ろにずらす
\t
0x09
カーソル位置を次のタブ位置に移動する
\n
0x0A
カーソル位置を次の行に移動(改行)
\f
0x0C
紙を排出する(プリンタの場合のみ)
\r
0x0D
カーソル位置を行の一番左に移動(Macでは改行)
\\
0x5C
\を表示する
\'
0x2C
'を表示する
\"
0x22
"を表示する
\?
0x3F
?を表示する
\digit
octalで同じ
対応するoctalのCharacter encodingを表示
\xdigit
digitと同じ
対応するhexadecimalのCharacter encodingを表示
"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.
デバッグ用Constant
Constant
意味
__LINE__
runされている行番号
__FILE__
runされているSource file名
__DATE__
コンパイルされたday付
__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.
この機能が他のprogramming言語にも欲しいよう・・・
整数型サイズのDefined constants
Constant
numericsの意味
CHAR_BIT
char型のビット単位のサイズ。
CHAR_MAX
char型の最大値。
CHAR_MIN
char型の最小値。
INT_MAX
int型の最大値。
INT_MIN
int型の最小値。
LONG_MAX
long型の最大値。
LONG_MIN
long型の最小値。
SCHAR_MAX
signed char型の最大値。
SCHAR_MIN
signed char型の最小値。
SHART_MAX
short型の最大値。
SHART_MIN
short型の最小値。
UCHAR_MAX
unsigned char型の最大値。
UINT_MAX
unsigned int型の最大値。
ULONG_MAX
unsigned long型の最大値。
USHRT_MAX
unsigned short型の最大値。
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.
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.