Programming-Idioms

History of Idiom 22 > diff from v38 to v39

Edit summary for version 39 :
[Cpp] cstdlib C++ standard header file is preferred

Version 38

2016-02-16, 16:44:42

Version 39

2016-02-16, 16:56:53

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Imports
#include <stdlib.h>
Imports
#include <cstdlib>
Code
int i = atoi(s);
Code
int i = std::atoi(s);
Comments bubble
s is a char*
Comments bubble
s is a char*
Doc URL
http://en.cppreference.com/w/cpp/string/byte/atoi