Remake of Joke pprogram in C++

edited April 2017 in Programming
Howdy all,

Since I read the topic in software about a program that "Drian's the water out of you hard disk", I have created a C++ version of it just for hells sake, and thought that some or many of you would get a kick out of it. First I gotta say, yes it is stupid, and It's probably not post worthy.. But it is something to laugh at. So take a look and see how I did.

Here's the source code:
#include <iostream>
#include <unistd.h> //For sleep()
#include <fstream>  // ofstream
#include <stdlib.h>   /** srand, rand */
#include <time.h>   // time
#include <stdio.h>    // NULL

/** Need write properties */
using namespace std;


void read() {

  // Declaring random seed
  srand (time(NULL));
  
  long int write;

  write = rand() % 3000000 + 1;

  ofstream read;
  read.open("read.txt");
  read << write << endl;
  read.close();

}

void loading (int limit, double speed) {
  int i = 0;
  cout << "-" << flush;
  do {
     usleep(speed);
     cout << "\b\\" << flush;
    usleep(speed);
    cout << "\b|" << flush;
    usleep(speed);
    cout << "\b/" << flush;
    usleep(speed);
    cout << "\b-" << flush;

   i++;
  }
  while (i < limit);
  cout << endl;
}

/** usleep() vs sleep() function:
  usleep use's milisecnonds
  sleep use's minutes (slower)..
*/

int main() {
  int limit = 500;
  double speed = 4300;

  cout << "Water detected in System Drive"<< endl << endl << "\a";

  cout << "Standbye while water is drained ";
  read();
  loading(limit, speed);
  cout << endl << "Spin dry cycle starting ";
  loading(limit, speed);

  cout << endl << "System OK now... you may proceed." << endl;
  
 return 0;
}

Comments

  • Today a prank mobile app would do better. I'm sure you'd convince a few people that downloading your app will get the water out of their phones. :P
  • Will it run in a VM using Windows 98 command prompt?

    I tried SomeGuy's oldie softs, and it just blipped - virtual machine was too fast to see the actual program I guess.
  • 02k-guy wrote:
    Will it run in a VM using Windows 98 command prompt?

    I tried SomeGuy's oldie softs, and it just blipped - virtual machine was too fast to see the actual program I guess.
    Hey sorry for the late reply, If you can compile it then it can certainly run on that OS. I have gotten to compile on TC++ on dos but had to strip the animation and the some if not most libraries.

    I'm going to try to use freedos sometime latter today and see if I can get the source code fully compiled for you. I probably wont post it until next week as finals are looming around the corner, and time to pass my 14 units. :|

    If you want to try this version that compiles on TC++ for dos here it is:
    #include <iostream>
    #include <fstream>  // ofstream
    #include <time.h>   // time
    
    void read() {
    
      // Declaring random seed
      srand (time(NULL));
     
      long int write;
    
      write = rand() % 3000000 + 1;
    
      ofstream read;
      read.open("read.txt");
      read << write << endl;
      read.close();
    
    }
    
    
    /** usleep() vs sleep() function:
      usleep use's milisecnonds
      sleep use's minutes (slower)..
    */
    
    int main() {
    
      cout << "Water detected in System Drive"<< endl << endl << "\a";
    
      cout << "Standbye while water is drained ";
      read();
      cout << endl << "Spin dry cycle starting ";
    
      cout << endl << "System OK now... you may proceed." << endl;
     
     return 0;
    }
    
  • Double post but what ever. I have finally compiled this in a windows 32 exe. The compiler you need is Borderland C++ 5.02 for Windows. This program has minor adjustments due to windows.h and the Sleep() function only working in seconds. I have also just for the fun of it made a lisence for my code:
    BSD-2-Clause License
    
    Copyright 2017 birdy (user at winworldpc.com/winboards/)
    
    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    
    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    
    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
    And the source code:
    #include <iostream>
    #include <windows.h> // For Sleep()
    #include <fstream>  // ofstream
    #include <stdlib.h>   /** srand, rand */
    #include <time.h>   // time
    #include <stdio.h>    // NULL
    
    void read() {
    
      // Declaring random seed
      srand (time(NULL));
    
      long int write;
    
      write = rand() % 3000000 + 1;
    
      ofstream read;
      read.open("read.txt");
      read << write << endl;
      read.close();
    
    }
    
    void loading (int limit, double speed) {
      int i = 0;
      cout << "-" << flush;
      do {
         Sleep(speed);
         cout << "\b\\" << flush;
        Sleep(speed);
        cout << "\b|" << flush;
        Sleep(speed);
        cout << "\b/" << flush;
        Sleep(speed);
        cout << "\b-" << flush;
    
       i++;
      }
      while (i < limit);
      cout << endl;
    }
    
    /** usleep() vs sleep() function:
      usleep use's milisecnonds
      sleep use's minutes (slower)..
    */
    
    int main() {
      int limit = 300;
      double speed = 4;
    
      cout << "Water detected in System Drive"<< endl << endl << "\a";
    
      cout << "Standbye while water is drained ";
      read();
      loading(limit, speed);
      cout << endl << "Spin dry cycle starting ";
      loading(limit, speed);
    
      cout << endl << "System OK now... you may proceed." << endl;
    
     return 0;
    }
    

    Enjoy.
Sign In or Register to comment.