Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
atoll.c
Go to the documentation of this file.
1 #include <ctype.h>
2 #include <stdbool.h>
3 #include <stdlib.h>
4 
5 long long atoll(const char* str)
6 {
7  long long val = 0;
8  bool neg = false;
9 
10  while(isspace(*str))
11  {
12  str++;
13  }
14 
15  switch(*str)
16  {
17  case '-':
18  neg = true;
19  // Intentional fallthrough
20  case '+':
21  str++;
22  }
23 
24  while(isdigit(*str))
25  {
26  val = (10 * val) + (*str++ - '0');
27  }
28  return neg ? -val : val;
29 }
long long atoll(const char *str)
Interprets a Long Long value in a byte string pointed to by str.
Definition: atoll.c:5
int isspace(int ch)
Checks if the given character is a whitespace character.
Definition: isspace.c:5
int isdigit(int ch)
Checks if the given character is a numeric character.
Definition: isdigit.c:5