Bug Two

This program compiles just fine. It even runs without a hitch ... until it tries to dereference a null pointer! Oh, how embarassing. But the real question is this: why is the number 2 never printed out? Each time the program is run, the output is always a series of alternating 1's and 3's, followed by a Segmentation fault. Where's the 2, dude?

An example output

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
	void *vp = 0;
	int i;
	srand(time(0));

	while (1) {
		printf("1");
		if ((rand() % 20000) == 3) {
			printf("2");
			i = *(int *)vp;
		}
		printf("3");
	}

	return 0;
}

Answer