Skip to content

Instantly share code, notes, and snippets.

@przemoc
Created November 21, 2010 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save przemoc/708845 to your computer and use it in GitHub Desktop.
Save przemoc/708845 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#define NUMBER 12345678901234567890
#define _Q(n) #n
#define Q(n) _Q(n)
#define ATOL(n) atol(Q(n))
#define SSCANF(n) ({ long val = 0; sscanf(Q(n), "%ld", &val); val; })
#define STRTOL(n) strtol(Q(n), NULL, 10)
#define PRINTL(n) printf("%.*lx\n", 2 * (int)sizeof(long), n)
#define PRINT(m, n) do { puts(#m); PRINTL(m(n)); PRINTL(m(-n)); } while (0);
int main()
{
puts(Q(NUMBER));
puts(Q(-NUMBER));
PRINT(ATOL, NUMBER);
PRINT(SSCANF, NUMBER);
PRINT(STRTOL, NUMBER);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment