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'.

ไทย

Parse จำนวนเต็ม

เปลี่ยน string เช่น "-123" ให้เป็นตัวเลข -123, ด้วยมือ — งานที่ atoi ทำ อ่านเครื่องหมายนำหน้า - ที่อาจมีเพื่อกำหนดเครื่องหมาย แล้วสร้างค่าหลักหน่วยต่อหลักหน่วย: หลักใหม่แต่ละหลักหมายถึง result = result * 10 + digit ตัวอักษรแปลงเป็นค่าหลักด้วย c - '0'

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP