About a month ago, at a LAN party, I was getting a bit bored (and tired as hell), so I decided to make a quick "update" program for my parents' computer. Often they'll ask me for help, and yell at me when they're confused. So, I decided to plan an April Fool's prank on them in advance. The program starts with "Upgrading Win98x -- Do not abort -- Do not abort -- Hard drive failure may result after abortion. Press any key to continue."

The program then continues to follow an algorithm to pick fairly plausible file name (my parents don't need real file names to believe it), and "update them", full with a percent counter. The thing is, it is in an infinite loop. So far, I've had my dad waiting for it to finish for an hour. I predict he will be waiting for quite some time longer.


The gig is up. I finally told my father after 5+ hours of running the program, and him not using the computer.


Source code in C++ (feel free to reproduce):



#include <iostream.h>
#include <time.h>  //gets time
#include <stdlib.h>
#include <conio.h>  //getch function

int rnd(int range);
void seedrnd(void);
void anykey();  //my own anykey fuction

void main()
{
	seedrnd();
	int lets;
	char consonants[22]="bcdfghjklmnpqrstvwxyz";
	char vowels[6]="aeiou";
	char letters[27]="abcdefghijklmnopqrstuvwyxz";
	char ext[34]="datexebatdllsyscfgpwlreghlpinisav";
	int name;
	int start;
	int percent;
	// starting message:
	cout << "----------------\nUpgrading Win98x -- Do not abort -- ";
	cout << "Do not abort\nHard drive failure may result after abortion";
	cout << "\n----------------\n";
	cout << "Press any key to continue";
	anykey();  //here's the quick anykey
	cout << "\n\n";
	while(;;)  // infinite loop
	{
		cout << "Updating: ";
		lets=rnd(7)+3;  //how many letters will the filename have?  3-7
		for(int i=0; i<lets; i++)
		{
			if(i==0||i==2||i==3||i==6||i==7)
//randomly picks the letter.
//First, third, fourth, seventh, and eighth letters are consonants
			{
				name=rnd(20);
				cout << consonants[name];
			}
			if(i==1||i==4||i==5)
//second, fifth, and sixth are vowels
//(for easy pronunciation of "filenames", and you don't get "gjwp.exe")
			{
				name=rnd(4);
				cout << vowels[name];
			}
		}
		lets=rnd(3)+1; // 1/3 chance of adding numbers
		if(lets==3)
		{
			lets=rnd(2)+1;  // either one or two numbers
			for(int i=0; i<lets; i++)
			{
				name=rnd(9)+1;  //numbers 1-9
				cout << name;
			}
			lets=rnd(2)+1;
// If the numbers are displayed,
//there is an additional 1/2 chance of additional letters
			if(lets==2)
			{
				lets=rnd(5)+1;
// 1-5 additional letters, these can be either consonant or vowel
				for(int i=0; i<lets; i++)
				{
					name=rnd(25);
					cout << letters[name];
				}
			}
		}
		cout << ".";
		lets=rnd(10);  // 10 different file extentions.
			// Some might even be known by my parents!
		lets=lets*3;
		cout << ext[lets] << ext[lets+1] << ext[lets+2];
		cout << "\n     ";
		percent=0;
		start=time(NULL);
		lets=rnd(5)+1;  // waits 1-5 seconds for next percent update.
		percent=0;
//this is the percent counter, doesn't work all that well,
//I'm thinking because of the speed of today's computers.
		while(percent!=100)
		{
			cout << percent << "%"; // displays percent
			while(time(NULL)-lets<start) //waiting
			{
			}
			if(percent<=9)
				cout << "\b\b";  // backspace (if you didn't know)
			if(percent>9)
				cout << "\b\b\b";
			percent=percent+1;
		}
		cout << "\n----File update complete\n";
	}
}

int rnd(int range)
{
	//do: int rnd(int range);
	//and: void seedrnd(void);
	//when I'm ready to call up a random number,
	//do it like this:
//variable=rndputhighestnumberhere+putlowestnumberhere;
	//in main when declaring int, etc, put: seedrnd();
	int r;

	r=rand()%range;
	return(r);
}

void seedrnd(void)
{
	srand((unsigned)time(NULL));
}

void anykey()
{
	cout << endl;
	getch();
}

Thanks to Magenta and OldMiner for pointing various things out to me to fix this writeup.