File: strtoi-1.c

package info (click to toggle)
dateutils 0.4.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,228 kB
  • sloc: ansic: 22,598; makefile: 1,771; yacc: 202; sh: 168; lex: 108
file content (24 lines) | stat: -rw-r--r-- 571 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include "strops.h"
#include "strops.c"
#include "nifty.h"

static const char *tst1[] = {"84", "52", "01", "99", "102", "120", "001", "4"};
static const char *tst0[] = {"8.4", "5a", "a1", "9.", "1+2", "", "\t", "#4"};

int
main(void)
{
	for (size_t i = 0U; i < countof(tst1); i++) {
		const char *x;
		int32_t r = strtoi_lim(tst1[i], &x, 0, 60);
		printf("%d %td\n", r, x - tst1[i]);
	}
	for (size_t i = 0U; i < countof(tst0); i++) {
		const char *x;
		int32_t r = strtoi_lim(tst0[i], &x, 0, 60);
		printf("%d %td\n", r, x - tst0[i]);
	}
	return 0;
}