Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*============================================================================
- ----------------------------------------------------------------------------
- weirder.c - ...and just when you think things couldn't get anymore fux0r3d.
- (c) Damion 'Phr0z3n.Dev' Tapper, 2013.
- Email: Phr0z3n.Dev@Gmail.com
- NOTE: void* - The 'pawn' of C Programming.
- ----------------------------------------------------------------------------
- ============================================================================*/
- #define USE_SEC_API /* Comment this line if you do not have the secure libraries. */
- #include <stdio.h>
- #include <stdlib.h> /* For calloc. */
- struct tempS
- {
- char *myString;
- }*tsp; /* This 'might' seem abnormal at first... */
- void* retVal(void *, void *);
- int main(void)
- {
- tsp = calloc(1, sizeof(struct tempS)); /* ...but now you see why it is not. */
- #ifdef USE_SEC_API
- printf_s("%d\n", retVal((void *)1, (void *)2)); /* The secure printf function (good programming practice). */
- printf_s("%llf\n", *(long double *)retVal((void *)2, NULL)); /* The 'weirder'ness starts here... */
- printf_s("%s\n", retVal((void *)3, NULL)); /* ...continues here... */
- printf_s(retVal(NULL, NULL));
- #else
- /* If you are lacking the secure libraries. */
- printf("%d\n", retVal((void *)1, (void *)2));
- printf("%llf\n", *(long double *)retVal((void *)2, NULL));
- printf("%s\n", retVal((void *)3, NULL));
- printf(retVal(NULL, NULL));
- #endif
- free(tsp); /* The actual prototype is free(void*) so I'm not the only weird guy around here. */
- return 0;
- }
- void* retVal(void *b, void *nada)
- {
- switch((int)b)
- {
- case 1:
- return (int *)(2 * (int)nada);
- case 2:
- { /* ... */
- long double *pi = calloc(1, sizeof(long double));
- *pi = (long double)22 / (long double)7;
- return pi;
- }
- case 3:
- return tsp->myString = "Hello World!"; /* ... */
- default:
- return "U R Phroz3n!"; /* ...it doesn't end here. It lives forever in your mind. */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement