Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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