Debian Codegraph @

templates/man3/strtol.3.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:45+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "strtol"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-08"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid "strtol, strtoll, strtoq - convert a string to a long integer"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "LIBRARY"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
61 #: opensuse-leap-16-1 opensuse-tumbleweed
62 msgid "Standard C library (I<libc>,\\ I<-lc>)"
63 msgstr ""
64
65 #. type: SH
66 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
67 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
68 #, no-wrap
69 msgid "SYNOPSIS"
70 msgstr ""
71
72 #. type: Plain text
73 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
74 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
75 #, no-wrap
76 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
77 msgstr ""
78
79 #. type: Plain text
80 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
81 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
82 #, no-wrap
83 msgid ""
84 "B<long strtol(const char *restrict >I<nptr>B<,>\n"
85 "B< char **_Nullable restrict >I<endptr>B<, int >I<base>B<);>\n"
86 "B<long long strtoll(const char *restrict >I<nptr>B<,>\n"
87 "B< char **_Nullable restrict >I<endptr>B<, int >I<base>B<);>\n"
88 msgstr ""
89
90 #. type: Plain text
91 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
92 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
93 msgid ""
94 "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
95 msgstr ""
96
97 #. type: Plain text
98 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
99 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
100 msgid "B<strtoll>():"
101 msgstr ""
102
103 #. type: Plain text
104 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
105 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
106 #, no-wrap
107 msgid ""
108 " _ISOC99_SOURCE\n"
109 " || /* glibc E<lt>= 2.19: */ _SVID_SOURCE || _BSD_SOURCE\n"
110 msgstr ""
111
112 #. type: SH
113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
115 #, no-wrap
116 msgid "DESCRIPTION"
117 msgstr ""
118
119 #. type: Plain text
120 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
121 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
122 msgid ""
123 "The B<strtol>() function converts the initial part of the string in I<nptr> "
124 "to a long integer value according to the given I<base>, which must be "
125 "between 2 and 36 inclusive, or be the special value 0."
126 msgstr ""
127
128 #. type: Plain text
129 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
130 #: opensuse-tumbleweed
131 msgid ""
132 "The string may begin with an arbitrary amount of white space (as determined "
133 "by B<isspace>(3)) followed by a single optional \\[aq]+\\[aq] or \\[aq]-\\"
134 "[aq] sign. If I<base> is zero or 16, the string may then include a \"0x\" "
135 "or \"0X\" prefix, and the number will be read in base 16; if I<base> is zero "
136 "or 2, the string may then include a \"0b\" or \"0B\" prefix, and the number "
137 "will be read in base 2; otherwise, a zero I<base> is taken as 10 (decimal) "
138 "unless the next character is \\[aq]0\\[aq], in which case it is taken as 8 "
139 "(octal)."
140 msgstr ""
141
142 #. type: Plain text
143 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
144 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
145 msgid ""
146 "The remainder of the string is converted to a I<long> value in the obvious "
147 "manner, stopping at the first character which is not a valid digit in the "
148 "given base. (In bases above 10, the letter \\[aq]A\\[aq] in either "
149 "uppercase or lowercase represents 10, \\[aq]B\\[aq] represents 11, and so "
150 "forth, with \\[aq]Z\\[aq] representing 35.)"
151 msgstr ""
152
153 #. type: Plain text
154 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
155 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
156 msgid ""
157 "If I<endptr> is not NULL, and the I<base> is supported, B<strtol>() stores "
158 "the address of the first invalid character in I<*endptr>. If there were no "
159 "digits at all, B<strtol>() stores the original value of I<nptr> in "
160 "I<*endptr> (and returns 0). In particular, if I<*nptr> is not \\[aq]\\"
161 "[rs]0\\[aq] but I<**endptr> is \\[aq]\\[rs]0\\[aq] on return, the entire "
162 "string is valid."
163 msgstr ""
164
165 #. type: Plain text
166 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
167 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
168 msgid ""
169 "The B<strtoll>() function works just like the B<strtol>() function but "
170 "returns a I<long long> integer value."
171 msgstr ""
172
173 #. type: SH
174 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
175 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
176 #, no-wrap
177 msgid "RETURN VALUE"
178 msgstr ""
179
180 #. type: Plain text
181 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
182 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
183 msgid ""
184 "The B<strtol>() function returns the result of the conversion, unless the "
185 "value would underflow or overflow. If an underflow occurs, B<strtol>() "
186 "returns B<LONG_MIN>. If an overflow occurs, B<strtol>() returns "
187 "B<LONG_MAX>. In both cases, I<errno> is set to B<ERANGE>. Precisely the "
188 "same holds for B<strtoll>() (with B<LLONG_MIN> and B<LLONG_MAX> instead of "
189 "B<LONG_MIN> and B<LONG_MAX>)."
190 msgstr ""
191
192 #. type: SH
193 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
194 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
195 #, no-wrap
196 msgid "ERRORS"
197 msgstr ""
198
199 #. type: Plain text
200 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
201 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
202 msgid "This function does not modify I<errno> on success."
203 msgstr ""
204
205 #. type: TP
206 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
207 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
208 #, no-wrap
209 msgid "B<EINVAL>"
210 msgstr ""
211
212 #. type: Plain text
213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
215 msgid "(not in C99) The given I<base> contains an unsupported value."
216 msgstr ""
217
218 #. type: TP
219 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
220 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
221 #, no-wrap
222 msgid "B<ERANGE>"
223 msgstr ""
224
225 #. type: Plain text
226 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
227 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
228 msgid "The resulting value was out of range."
229 msgstr ""
230
231 #. type: Plain text
232 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
233 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
234 msgid ""
235 "The implementation may also set I<errno> to B<EINVAL> in case no conversion "
236 "was performed (no digits seen, and 0 returned)."
237 msgstr ""
238
239 #. type: SH
240 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
241 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
242 #, no-wrap
243 msgid "ATTRIBUTES"
244 msgstr ""
245
246 #. type: Plain text
247 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
248 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
249 msgid ""
250 "For an explanation of the terms used in this section, see B<attributes>(7)."
251 msgstr ""
252
253 #. type: tbl table
254 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
255 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
256 #, no-wrap
257 msgid "Interface"
258 msgstr ""
259
260 #. type: tbl table
261 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
262 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
263 #, no-wrap
264 msgid "Attribute"
265 msgstr ""
266
267 #. type: tbl table
268 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
269 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
270 #, no-wrap
271 msgid "Value"
272 msgstr ""
273
274 #. type: tbl table
275 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
276 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
277 #, no-wrap
278 msgid ".na\n"
279 msgstr ""
280
281 #. type: tbl table
282 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
283 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
284 #, no-wrap
285 msgid ".nh\n"
286 msgstr ""
287
288 #. type: tbl table
289 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
290 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
291 #, no-wrap
292 msgid ""
293 "B<strtol>(),\n"
294 "B<strtoll>(),\n"
295 "B<strtoq>()"
296 msgstr ""
297
298 #. type: tbl table
299 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
300 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
301 #, no-wrap
302 msgid "Thread safety"
303 msgstr ""
304
305 #. type: tbl table
306 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
307 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
308 #, no-wrap
309 msgid "MT-Safe locale"
310 msgstr ""
311
312 #. type: SH
313 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
314 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
315 #, no-wrap
316 msgid "VERSIONS"
317 msgstr ""
318
319 #. type: Plain text
320 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
321 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
322 msgid ""
323 "According to POSIX.1, in locales other than \"C\" and \"POSIX\", these "
324 "functions may accept other, implementation-defined numeric strings."
325 msgstr ""
326
327 #. type: Plain text
328 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
329 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
330 msgid "BSD also has"
331 msgstr ""
332
333 #. type: Plain text
334 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
335 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
336 #, no-wrap
337 msgid "B<quad_t strtoq(const char *>I<nptr>B<, char **>I<endptr>B<, int >I<base>B<);>\n"
338 msgstr ""
339
340 #. type: Plain text
341 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
342 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
343 msgid ""
344 "with completely analogous definition. Depending on the wordsize of the "
345 "current architecture, this may be equivalent to B<strtoll>() or to "
346 "B<strtol>()."
347 msgstr ""
348
349 #. type: SH
350 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
351 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
352 #, no-wrap
353 msgid "STANDARDS"
354 msgstr ""
355
356 #. type: Plain text
357 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
358 #: opensuse-tumbleweed
359 msgid "C23, POSIX.1-2024."
360 msgstr ""
361
362 #. type: SH
363 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
364 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
365 #, no-wrap
366 msgid "HISTORY"
367 msgstr ""
368
369 #. type: TP
370 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
371 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
372 #, no-wrap
373 msgid "B<strtol>()"
374 msgstr ""
375
376 #. type: Plain text
377 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
378 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
379 msgid "POSIX.1-2001, C89, SVr4, 4.3BSD."
380 msgstr ""
381
382 #. type: TP
383 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
384 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
385 #, no-wrap
386 msgid "B<strtoll>()"
387 msgstr ""
388
389 #. type: Plain text
390 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
391 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
392 msgid "POSIX.1-2001, C99."
393 msgstr ""
394
395 #. type: TP
396 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
397 #: opensuse-tumbleweed
398 #, no-wrap
399 msgid "\"0b\", \"0B\""
400 msgstr ""
401
402 #. type: Plain text
403 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
404 #: opensuse-tumbleweed
405 msgid "C23. glibc 2.38. (Not in POSIX.)"
406 msgstr ""
407
408 #. type: SH
409 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
410 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
411 #, no-wrap
412 msgid "CAVEATS"
413 msgstr ""
414
415 #. type: SS
416 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
417 #: opensuse-tumbleweed
418 #, no-wrap
419 msgid "Range checks"
420 msgstr ""
421
422 #. type: Plain text
423 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
424 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
425 msgid ""
426 "Since B<strtol>() can legitimately return 0, B<LONG_MAX>, or B<LONG_MIN> "
427 "(B<LLONG_MAX> or B<LLONG_MIN> for B<strtoll>()) on both success and "
428 "failure, the calling program should set I<errno> to 0 before the call, and "
429 "then determine if an error occurred by checking whether I<errno == ERANGE> "
430 "after the call."
431 msgstr ""
432
433 #. type: Plain text
434 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
435 #: opensuse-tumbleweed
436 #, no-wrap
437 msgid ""
438 "errno = 0;\n"
439 "n = strtol(s, &end, base);\n"
440 "if (end == s)\n"
441 "\tgoto no_number;\n"
442 "if ((errno == ERANGE && n == _Minof(long)) || n E<lt> min)\n"
443 "\tgoto too_low;\n"
444 "if ((errno == ERANGE && n == _Maxof(long)) || n E<gt> max)\n"
445 "\tgoto too_high;\n"
446 msgstr ""
447
448 #. type: SS
449 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
450 #: opensuse-tumbleweed
451 #, no-wrap
452 msgid "base"
453 msgstr ""
454
455 #. type: Plain text
456 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
457 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
458 msgid ""
459 "If the I<base> needs to be tested, it should be tested in a call where the "
460 "string is known to succeed. Otherwise, it's impossible to portably "
461 "differentiate the errors."
462 msgstr ""
463
464 #. type: Plain text
465 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
466 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
467 #, no-wrap
468 msgid ""
469 "errno = 0;\n"
470 "strtol(\"0\", NULL, base);\n"
471 "if (errno == EINVAL)\n"
472 " goto unsupported_base;\n"
473 msgstr ""
474
475 #. type: SH
476 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
477 #: opensuse-tumbleweed
478 #, no-wrap
479 msgid "BUGS"
480 msgstr ""
481
482 #. type: SS
483 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
484 #: opensuse-tumbleweed
485 #, no-wrap
486 msgid "White space"
487 msgstr ""
488
489 #. type: Plain text
490 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
491 #: opensuse-tumbleweed
492 msgid ""
493 "These functions silently accept leading white space. To reject white space, "
494 "call B<isspace>(3) before B<strtol>()."
495 msgstr ""
496
497 #. type: SH
498 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
499 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
500 #, no-wrap
501 msgid "EXAMPLES"
502 msgstr ""
503
504 #. type: Plain text
505 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
506 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
507 msgid ""
508 "The program shown below demonstrates the use of B<strtol>(). The first "
509 "command-line argument specifies a string from which B<strtol>() should "
510 "parse a number. The second (optional) argument specifies the base to be "
511 "used for the conversion. (This argument is converted to numeric form using "
512 "B<atoi>(3), a function that performs no error checking and has a simpler "
513 "interface than B<strtol>().) Some examples of the results produced by this "
514 "program are the following:"
515 msgstr ""
516
517 #. type: Plain text
518 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
519 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
520 #, no-wrap
521 msgid ""
522 "$B< ./a.out 123>\n"
523 "strtol() returned 123\n"
524 "$B< ./a.out \\[aq] 123\\[aq]>\n"
525 "strtol() returned 123\n"
526 "$B< ./a.out 123abc>\n"
527 "strtol() returned 123\n"
528 "Further characters after number: \"abc\"\n"
529 "$B< ./a.out 123abc 55>\n"
530 "strtol: Invalid argument\n"
531 "$B< ./a.out \\[aq]\\[aq]>\n"
532 "No digits were found\n"
533 "$B< ./a.out 4000000000>\n"
534 "strtol: Numerical result out of range\n"
535 msgstr ""
536
537 #. type: SS
538 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
539 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
540 #, no-wrap
541 msgid "Program source"
542 msgstr ""
543
544 #. type: Plain text
545 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
546 #: opensuse-tumbleweed
547 #, no-wrap
548 msgid ""
549 "#include E<lt>errno.hE<gt>\n"
550 "#include E<lt>stdio.hE<gt>\n"
551 "#include E<lt>stdlib.hE<gt>\n"
552 "\\&\n"
553 "int\n"
554 "main(int argc, char *argv[])\n"
555 "{\n"
556 " int base;\n"
557 " char *endptr, *str;\n"
558 " long val;\n"
559 "\\&\n"
560 " if (argc E<lt> 2) {\n"
561 " fprintf(stderr, \"Usage: %s str [base]\\[rs]n\", argv[0]);\n"
562 " exit(EXIT_FAILURE);\n"
563 " }\n"
564 "\\&\n"
565 " str = argv[1];\n"
566 " base = (argc E<gt> 2) ? atoi(argv[2]) : 0;\n"
567 "\\&\n"
568 " errno = 0; /* To distinguish success/failure after call */\n"
569 " strtol(\"0\", NULL, base);\n"
570 " if (errno == EINVAL) {\n"
571 " perror(\"strtol\");\n"
572 " exit(EXIT_FAILURE);\n"
573 " }\n"
574 "\\&\n"
575 " errno = 0; /* To distinguish success/failure after call */\n"
576 " val = strtol(str, &endptr, base);\n"
577 "\\&\n"
578 " /* Check for various possible errors. */\n"
579 "\\&\n"
580 " if (errno == ERANGE) {\n"
581 " perror(\"strtol\");\n"
582 " exit(EXIT_FAILURE);\n"
583 " }\n"
584 "\\&\n"
585 " if (endptr == str) {\n"
586 " fprintf(stderr, \"No digits were found\\[rs]n\");\n"
587 " exit(EXIT_FAILURE);\n"
588 " }\n"
589 "\\&\n"
590 " /* If we got here, strtol() successfully parsed a number. */\n"
591 "\\&\n"
592 " printf(\"strtol() returned %ld\\[rs]n\", val);\n"
593 "\\&\n"
594 " if (*endptr != \\[aq]\\[rs]0\\[aq]) /* Not necessarily an error. */\n"
595 " printf(\"Further characters after number: \\[rs]\"%s\\[rs]\"\\[rs]n\", endptr);\n"
596 "\\&\n"
597 " exit(EXIT_SUCCESS);\n"
598 "}\n"
599 msgstr ""
600
601 #. SRC END
602 #. type: SH
603 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
604 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
605 #, no-wrap
606 msgid "SEE ALSO"
607 msgstr ""
608
609 #. type: Plain text
610 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
611 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
612 msgid ""
613 "B<atof>(3), B<atoi>(3), B<atol>(3), B<strtod>(3), B<strtoimax>(3), "
614 "B<strtoul>(3)"
615 msgstr ""
616
617 #. type: TH
618 #: debian-trixie
619 #, no-wrap
620 msgid "2024-06-16"
621 msgstr ""
622
623 #. type: TH
624 #: debian-trixie
625 #, no-wrap
626 msgid "Linux man-pages 6.9.1"
627 msgstr ""
628
629 #. type: Plain text
630 #: debian-trixie
631 msgid "Standard C library (I<libc>, I<-lc>)"
632 msgstr ""
633
634 #. type: Plain text
635 #: debian-trixie fedora-44 fedora-rawhide
636 msgid ""
637 "The string may begin with an arbitrary amount of white space (as determined "
638 "by B<isspace>(3)) followed by a single optional \\[aq]+\\[aq] or \\[aq]-\\"
639 "[aq] sign. If I<base> is zero or 16, the string may then include a \"0x\" "
640 "or \"0X\" prefix, and the number will be read in base 16; otherwise, a zero "
641 "I<base> is taken as 10 (decimal) unless the next character is \\[aq]0\\[aq], "
642 "in which case it is taken as 8 (octal)."
643 msgstr ""
644
645 #. type: Plain text
646 #: debian-trixie fedora-44 fedora-rawhide
647 msgid "C11, POSIX.1-2008."
648 msgstr ""
649
650 #. type: Plain text
651 #: debian-trixie fedora-44 fedora-rawhide
652 #, no-wrap
653 msgid ""
654 "#include E<lt>errno.hE<gt>\n"
655 "#include E<lt>stdio.hE<gt>\n"
656 "#include E<lt>stdlib.hE<gt>\n"
657 "\\&\n"
658 "int\n"
659 "main(int argc, char *argv[])\n"
660 "{\n"
661 " int base;\n"
662 " char *endptr, *str;\n"
663 " long val;\n"
664 "\\&\n"
665 " if (argc E<lt> 2) {\n"
666 " fprintf(stderr, \"Usage: %s str [base]\\[rs]n\", argv[0]);\n"
667 " exit(EXIT_FAILURE);\n"
668 " }\n"
669 "\\&\n"
670 " str = argv[1];\n"
671 " base = (argc E<gt> 2) ? atoi(argv[2]) : 0;\n"
672 "\\&\n"
673 " errno = 0; /* To distinguish success/failure after call */\n"
674 " strtol(\"0\", NULL, base);\n"
675 " if (errno == EINVAL) {\n"
676 " perror(\"strtol\");\n"
677 " exit(EXIT_FAILURE);\n"
678 " }\n"
679 "\\&\n"
680 " errno = 0; /* To distinguish success/failure after call */\n"
681 " val = strtol(str, &endptr, base);\n"
682 "\\&\n"
683 " /* Check for various possible errors. */\n"
684 "\\&\n"
685 " if (errno == ERANGE) {\n"
686 " perror(\"strtol\");\n"
687 " exit(EXIT_FAILURE);\n"
688 " }\n"
689 "\\&\n"
690 " if (endptr == str) {\n"
691 " fprintf(stderr, \"No digits were found\\[rs]n\");\n"
692 " exit(EXIT_FAILURE);\n"
693 " }\n"
694 "\\&\n"
695 " /* If we got here, strtol() successfully parsed a number. */\n"
696 "\\&\n"
697 " printf(\"strtol() returned %ld\\[rs]n\", val);\n"
698 "\\&\n"
699 " if (*endptr != \\[aq]\\[rs]0\\[aq]) /* Not necessarily an error... */\n"
700 " printf(\"Further characters after number: \\[rs]\"%s\\[rs]\"\\[rs]n\", endptr);\n"
701 "\\&\n"
702 " exit(EXIT_SUCCESS);\n"
703 "}\n"
704 msgstr ""
705
706 #. type: TH
707 #: fedora-44 fedora-rawhide
708 #, no-wrap
709 msgid "2024-07-23"
710 msgstr ""
711
712 #. type: TH
713 #: fedora-44 fedora-rawhide
714 #, no-wrap
715 msgid "Linux man-pages 6.13"
716 msgstr ""
717
718 #. type: TH
719 #: mageia-cauldron
720 #, no-wrap
721 msgid "Linux man-pages 6.17"
722 msgstr ""
723
724 #. type: TH
725 #: opensuse-leap-16-1 opensuse-tumbleweed
726 #, no-wrap
727 msgid "Linux man-pages (unreleased)"
728 msgstr ""