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
#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);
}
gcc filename.c -Wall -ansi -pedantic -o filename