Created
November 21, 2010 16:02
-
-
Save przemoc/708845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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