Skip to content · ⁨Pular para o conteúdo⁩

Parse an integer · ⁨Analisar um inteiro⁩

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

Português

Parseie um inteiro

Transforme uma string como "-123" no número -123, manualmente — a função atoi faz isso. Leia um opcional leading - para ajustar o sinal, depois construa o valor dígito por dígito: cada novo dígito significa result = result * 10 + digit. Um caractere converte para seu valor numérico com c - '0'.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP