Skip to content

Instantly share code, notes, and snippets.

@danielhams
Last active February 17, 2020 20:40
Show Gist options
  • Save danielhams/d1e97c76da22cbe6367bfc05daf1c721 to your computer and use it in GitHub Desktop.
Save danielhams/d1e97c76da22cbe6367bfc05daf1c721 to your computer and use it in GitHub Desktop.
Twilight Zone
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main(int argc, char **argv)
{
size_t llsize = sizeof(long long);
printf("Size of long long is %llu\n", llsize );
const char * testuintmax = "2147483647";
char * oobll = "1234567890123456789012345678901234567890";
int vi = atoi(testuintmax);
printf("With atoi errno=%d value=%d\n",errno,vi);
long long vll1 = strtoll(testuintmax,NULL,10);
printf("With strtoll errno=%d value=%li\n",errno,vll1);
char * oobll_end;
long vll2 = strtol(oobll,&oobll_end,10);
printf("With strtol errno=%d value=%ld\n",errno,vll2);
errno=0;
long long vll3 = strtoll(testuintmax,NULL,10);
printf("With strtoll errno=%d value=%li\n",errno,vll3);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment