1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <stdio.h>
/* We only handle base 10. */
unsigned long long int strtoull(char *nptr, char **endptr, int base) {
unsigned long long int retval = 0;
char *idx = NULL;
for (idx = nptr; *idx != '\0' && isdigit(*idx); idx++) {
retval *= 10;
retval += (*idx - '0');
}
if (endptr != NULL) {
*endptr = idx;
}
return(retval);
}
|
|
>
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <stdio.h>
/* We only handle base 10. */
unsigned long long int strtoull(const char *nptr, char **endptr, int base) {
unsigned long long int retval = 0;
const char **endptrd = (const char **) endptr;
char *idx = NULL;
for (idx = nptr; *idx != '\0' && isdigit(*idx); idx++) {
retval *= 10;
retval += (*idx - '0');
}
if (endptrd != NULL) {
*endptrd = idx;
}
return(retval);
}
|