.TH atol() "" "" "General Function (libc)"
.PC "Convert ASCII strings to long integers"
.B "#include <stdlib.h>"
\fBlong atol(\fIstring\^\fB) char *\fIstring\^\fB;\fR
.PP
.B atol()
converts the argument
.I string
to a binary representation of a
.BR long .
.I string
may contain a leading sign (but no trailing sign)
and any number of decimal digits.
.B atol()
ignores leading blanks and tabs;
it stops scanning when it encounters any
non-numeral other than the leading sign,
and returns the resulting
.BR long .
.SH Example
.DM
#include <stdlib.h>
.DE
.DM
main()
{
	extern char *gets();
	extern long atol();
	char string[64];
.DE
.DM
	for(;;) {
		printf("Enter numeric string: ");
		if(gets(string))
			printf("%ld\en", atol(string));
		else
			break;
	}
}
.DE
.SH "See Also"
.Xr atof(), atof
.Xr atoi(), atoi
.Xr float, float
.Xr libc, libc
.Xr long, long
.Xr printf(), printf
.Xr scanf(), scanf
.Xr stdlib.h stdlib.h
.br
\*(AS, \(sc7.10.1.3
.br
\*(PX Standard, \(sc8.1
.SH Notes
No overflow checks are performed.
.B atol()
returns zero if it receives a string it cannot interpret.
