XINU
|
ASCII文字列をint型の整数に変換する。 More...
Go to the source code of this file.
Functions | |
int | atoi (char *p) |
ASCII文字列をint型に変換する。 More... | |
ASCII文字列をint型の整数に変換する。
Definition in file atoi.c.
int atoi | ( | char * | p | ) |
ASCII文字列をint型に変換する。
処理の流れは、
Step1. 「不要な文字(空白、TAB)の削除」もしくは「正数/負数の判定」を行う
Step2. 0〜9の範囲の値であれば、一桁ずつ記録する。それ以外の文字は呼び飛ばす
ASCIIコードとして、0=0x30、1=0x31、2=0x32、…、9=0x39であるため、
「0x30〜0x39の範囲のASCIIコード値(0〜9の値) - '0'(=0x30)」と計算すれば、
0〜9の整数値が得られる。
Step3. Step.1で取得した符号情報(±)を反映した整数を返す。
[in] | p | ASCII文字列 |
Definition at line 19 of file atoi.c.
Referenced by xsh_udpecho().