|
|
1.1 root 1:
2:
3: atol() General Function atol()
4:
5:
6:
7:
8: Convert ASCII strings to long integers
9:
10: lloonngg aattooll(_s_t_r_i_n_g) cchhaarr *_s_t_r_i_n_g;
11:
12: atol converts the argument string to a binary representation of a
13: long. string may contain a leading sign (but no trailing sign)
14: and any number of decimal digits. atol ignores leading blanks
15: and tabs; it stops scanning when it encounters any non-numeral
16: other than the leading sign, and returns the resulting long.
17:
18: ***** Example *****
19:
20:
21:
22: main()
23: {
24: extern char *gets();
25: extern long atol();
26: char string[64];
27:
28:
29:
30: for(;;) {
31: printf("Enter numeric string: ");
32: if(gets(string))
33: printf("%ld\n", atol(string));
34: else
35: break;
36: }
37: }
38:
39:
40: ***** See Also *****
41:
42: atof(), atoi(), float, long, printf(), scanf()
43:
44: ***** Notes *****
45:
46: No overflow checks are performed. atol returns zero if it
47: receives a string it cannot interpret.
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.