Skip to content · ⁨コンテンツへスキップ⁩

Parse an integer · ⁨整数を解析する⁩

English

Parse an integer

Turn a string like "-123" into the number -123, by hand — the job atoi does. Read an optional leading - to fix the sign, then build the value digit by digit: each new digit means result = result * 10 + digit. A character converts to its digit value with c - '0'.

日本語

整数をパースする

"-123" のような文字列を手動で数字 -123 に変換します——これは atoi が行う作業です。符号を固定するために任意の先頭の - を読み取り、その後桁ごとに値を構築します:新しい桁が来れば result = result * 10 + digit 倍します。文字は c - '0' で桁の値に変換されます。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP