Advertisement
Stiepen

troll.h - Fu** up all code

Apr 23rd, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. /*
  2.     Troll Header file by Kilobyte. Including this WILL make your program a single bug.
  3.     I am pretty sure most applications won't even launch with it lol :P
  4.     (Hint: include on April first)
  5.  
  6.     CHANGELOG:
  7.         1.0.1
  8.             Added Fake Segfault with a 0.25% chance on every output
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <signal.h>
  13. #ifdef __cplusplus
  14. #include <iostream>
  15. #include <cstdlib>
  16. #endif
  17.  
  18. bool troll_initialized;
  19.  
  20. void init_troll(void) {
  21.     if (troll_initialized)
  22.         return;
  23.     srand(0);
  24.     troll_initialized = true;
  25. }
  26.  
  27. void printtroll(char* x) {
  28.     init_troll();
  29.     if (rand() % 100 == 0)
  30.         printf("The author of this application sucks\n");
  31.     printf(x);
  32.     if (rand() % 400 == 0)
  33.         raise(SIGSEGV); // Yes, i am really evil...
  34. }
  35.  
  36. int maybe(void) {
  37.     init_troll();
  38.     int randomval = rand() % 100;
  39.     return randomval;
  40. }
  41.  
  42. #ifdef __cplusplus
  43. char* trollout(int chance) {
  44.     init_troll();
  45.     if (rand() % 400 == 0)
  46.         raise(SIGSEGV);
  47.     if (rand() % 100 < chance)
  48.         return "The author of this application sucks\n";
  49.     return "";
  50. }
  51. #endif
  52.  
  53. #undef true
  54. #undef false
  55.  
  56. #define printf(x) printtroll(x)
  57.  
  58. #define true maybe()  // make booleans undecided
  59. #define false !maybe()
  60.  
  61. #ifdef __cplusplus
  62. #define cout cout << trollout(1)
  63. #define cerrt cerr << trollout(5)
  64.  
  65. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement