This function converts a string of to a long integer.
If s is not convertable (for example if s=="a"), atoi should create a StringException, but it does not!
Note: atoi returns zero or the first part of numbers it could convert.
Example:
try {
writefln(atoi(cast(char[])"55"));
} catch {
writefln("Exception with '55'");
}
try {
writefln(atoi(cast(char[])"55a"));
} catch {
writefln("Exception with '55a'");
}
try {
writefln(atoi(cast(char[])"z"));
} catch {
writefln("Exception with 'z'");
}
|
Output:
See also:
Try statements,
atof,
toString
|