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이 수행하는 작업입니다. 부호를 고정하기 위해 선택적 선두 -을 읽고, 각 새로운 digit가 result = result * 10 + digit을 의미하도록 digit별로 값을 구성합니다. 문자는 c - '0'을 통해 해당 digit 값으로 변환됩니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP