Skip to content · ⁨Passer au contenu⁩

Parse an integer · ⁨Analyser un entier⁩

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

Français

Parser un entier

Transformez une chaîne comme "-123" en le nombre -123, à la main — le travail que fait atoi. Lisez un - optionnel au début pour fixer le signe, puis construisez la valeur chiffre par chiffre : chaque nouveau chiffre signifie result = result * 10 + digit. Un caractère se convertit en sa valeur numérique avec c - '0'.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP