Advertisement
Sealington3

tiny_virus.c

Dec 29th, 2023
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. // tiny_virus.c
  6. // Copyright (c) @Sealington 2023
  7. // Licensed under M.I.T
  8. // ------------------------------
  9.  
  10. int main() {
  11.     // memory allocation
  12.     size_t size_in_bytes = 5 * 1024 * 1024; // 5mb
  13.     char *data = (char *)malloc(size_in_bytes);
  14.  
  15.     if (data == NULL) {
  16.         fprintf(stderr, "oppsies!\n");
  17.         return 1;
  18.     }
  19.  
  20.     char userInput[256];
  21.     do {
  22.         printf("This is a virus, if you want your computer back, give me your money. [y/n]: ");
  23.         fgets(userInput, sizeof(userInput), stdin);
  24.         userInput[strcspn(userInput, "\n")] = '\0'; // configure the input
  25.     } while (strcmp(userInput, "y") != 0 && strcmp(userInput, "n") != 0);
  26.  
  27.     if (strcmp(userInput, "y") == 0) {
  28.       free(data);
  29.       printf("Your computer is free! It was never in true danger, anyways.\n");
  30.     } else {
  31.       free(data);
  32.       printf("your free to go :3\n");
  33.     }
  34.  
  35.     return 0;
  36. }
Tags: virus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement