Created
April 11, 2021 10:11
-
-
Save kwannoel/b4e3d586737275b7a292d8e60f5df8a8 to your computer and use it in GitHub Desktop.
Increment trigger until you see output upon program crash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int *ip = NULL; //just a convenient way to crash a program :-) | |
int i, trigger; | |
printf("Trigger at (positive int): "); | |
scanf("%d", &trigger); | |
for(i = 0; ; i++) { // essentially an infinite loop | |
printf("%d", i%10); | |
if (i == trigger) | |
*ip = 123; //boom! | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Observe that low
trigger
values do not output anything. This is because output is buffered. Only high values such as10000
, output gets written, because buffer size is filled.Also
\n
causes buffer to flush.