aboutsummaryrefslogtreecommitdiff
path: root/src/monkey/bug_null_pointer_exception.c
blob: 977fb088c364af74511b15430ddc567c1300362f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <string.h>

void crashFunction() 
{
	//char *stringCannotBeChanged = "String cannot be changed!";
	char *nullString = NULL;
	
	printf("Now the program will crash! Take a cover! \n");
	//*stringCannotBeChanged = 'h';
	printf("Nonsense!\n");
	if (strcmp(nullString, "A string to compare with") == 0) {
		printf("How come?! It had to be crashed!\n");
	}
}

int main(int argc, char *argv[]) 
{
	int i;
	printf("arguments: %d\n", argc);
	for (i=0; i<argc; i++)
		printf("%d: %s\n", i, argv[i]);
	printf("Press ENTER\n");
	getchar();
	crashFunction();
	return 0;
}