This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
Idiom #22 Convert string to integer
Extract the integer value i from its string representation s (in radix 10)

- Ada
- C
- C
- Clojure
- Clojure
- C++
- C++
- C++
- C++
- C#
- C#
- D
- Dart
- Elixir
- Erlang
- Fortran
- Go
- Go
- Groovy
- Haskell
- JS
- JS
- JS
- Java
- Java
- Java
- Java
- Kotlin
- Kotlin
- Lisp
- Lua
- Obj-C
- PHP
- Pascal
- Perl
- Python
- Ruby
- Rust
- Rust
- Rust
- Scala
- Scheme
- Smalltalk
- VB
i = (int)strtol(s, (char **)NULL, 10);
The atoi() function has been deprecated by strtol()
int i = Integer.parseInt(s);
Throws NumberFormatException if s does not contain a parsable integer
int i = new Integer(s).intValue();
Throws NumberFormatException if s does not contain a parsable integer