Results 1 to 2 of 2
One day while pondering about C I came up with this program. Can you predict what the answer will be? Now run it, were you right?
filename.c
Code:
#include <stdio.h>
...
- 01-01-2010 #1
C Brain Teaser For The New Year
One day while pondering about C I came up with this program. Can you predict what the answer will be? Now run it, were you right?
filename.c
gcc filename.c -Wall -ansi -pedantic -o filenameCode:#include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { unsigned long *iptr = (unsigned long*)0;/*pointer equals 0*/ unsigned long ans = (unsigned long)(iptr + 1);/*add 1 to the pointer*/ fprintf(stdout, "and the answer is->%lu\n", ans);/*whats the answer?*/ exit(EXIT_SUCCESS); }Make mine Arch Linux
- 01-02-2010 #2
I was wrong

EDIT:
But now I know why
Last edited by GNU-Fan; 01-02-2010 at 08:46 AM.
Debian GNU/Linux -- You know you want it.


Reply With Quote
