Header File
stdlib.h
Category
Conversion Routines, Math Routines
Prototype
long atol(const char *s);
long _wtol(const wchar_t *s);
Description
Converts a string to a long.
[ws] [sn] [ddd]
In this function, the first unrecognized character ends the conversion. There are no provisions for overflow in atol (results are undefined).
Return Value
atol returns the converted value of the input string. If the string cannot be converted to a number of the corresponding type (b), atol returns 0.
Example
#include <stdlib.h> #include <stdio.h> int main(void) { long l; char *lstr = "98765432"; l = atol(lstr); printf("string = %s integer = %ld\n", lstr, l); return(0); }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
atol |
+ |
+ |
+ |
+ |
_wtol |
|
+ |
|
|
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|