aboutsummaryrefslogtreecommitdiff
path: root/src/monkey/bug_null_pointer_exception.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/monkey/bug_null_pointer_exception.c')
-rw-r--r--src/monkey/bug_null_pointer_exception.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/monkey/bug_null_pointer_exception.c b/src/monkey/bug_null_pointer_exception.c
new file mode 100644
index 000000000..27428816d
--- /dev/null
+++ b/src/monkey/bug_null_pointer_exception.c
@@ -0,0 +1,27 @@
1#include <stdio.h>
2#include <string.h>
3
4void crashFunction()
5{
6 //char *stringCannotBeChanged = "String cannot be changed!";
7 char *nullString = NULL;
8
9 printf("Now the program will crash! Take a cover! \n");
10 //*stringCannotBeChanged = 'h';
11 printf("Nonsense!\n");
12 if (strcmp(nullString, "A string to compare with") == 0) {
13 printf("How come?! It had to be crashed!\n");
14 }
15}
16
17int main(int argc, char *argv[])
18{
19 int i = 0;
20 printf("arguments: %d\n", argc);
21 for (i=0; i<argc; i++)
22 printf("%d: %s\n", i, argv[i]);
23 printf("Press ENTER\n");
24 getchar();
25 crashFunction();
26 return 0;
27}