nocpp
[oweals/gnunet.git] / src / monkey / bug_null_pointer_exception.c
1 #include <stdio.h>
2 #include <string.h>
3
4 void 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
17 int main(int argc, char *argv[]) 
18 {
19         int i;
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 }