Parse an integer · 整数を解析する
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' で桁の値に変換されます。
Complete int parse_int(const char *s) that converts a string of digits (with an optional leading -) to its integer value, without using library functions like atoi. · int parse_int(const char *s) を完成させて、文字列の桁(前面に任意の - が付く場合を含む)を整数値に変換します。atoi のようなライブラリ関数を使用しないでください。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。