nonononono. I have found that this is a very helpful technique. I'm a gamer and somtimes i like to download games (such as Cabal online, wich takes 3 hours to download) and i dont like leaving my computer on for 12 hours straight if it's 10:00pm and i have to sleep. I have encountered these kinds of senarios where a delayed shutdown (in command prompt it is "shutdown.exe /s /f /t [time in second]) would be helpful to a user who takes good care of his or her computer. I already created a program that does this in the BASIC language and i want to excersize it useing C++. This would tech me how to write files, read from files and run files, calculate math, and integrate a consol menu all using C++.
btw, im only a beginner, so i would probably end up screwing myself trying to make a virus anyway.
so, that aside, i have already made some code for this little project of mine, but it seems to not execute the functions within. It's really wierd. If you could help me, that would be great. Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int ms (int minutes)
{
int sec;
sec = (minutes * 60);
return sec;
}
int shutdn ()
{
unsigned int sec;
string c;
unsigned int minutes;
cout<< "Give then number of minutes until shutdown: "<< endl; cin>> minutes;
sec = ms (minutes);
cout<< "Seconds until Shutdown: "<< sec<< endl;
cout<< "Press enter to continue: ";
cin.get();
cin.get();
int main();
}
int mh (float min, float hour)
{
min = (min / 60);
hour = (hour + min);
return hour;
}
int diftim ()
{
//declares all of the variables used in this function
unsigned int hours;
unsigned int minutes;
unsigned int h;
unsigned int m;
float tot1;
float tot2;
float tot3;
string ap;
string ap2;
unsigned int h2;
unsigned int m2;
//gets input from the user
cout<< "Hour: "<< endl;
cin>> h;
cout<< "Minute: "<< endl;
cin>> m;
cout<< "AM/PM?"<< endl;
cin>> ap;
cout<< "Second hour: "<< endl;
cin>> h2;
cout<< "Second minute: "<< endl;
cin>> m2;
cout<< "AM/PM?"<< endl;
cin>> ap2;
if (ap == "pm")
{
h = (h + 12);
}
if (ap2 == "pm")
{
h2 = (h2 + 12);
}
tot1 = mh (m, h);
tot2 = mh (m2, h2);
tot3 = (tot1 - tot2);
hours = int(tot3);
minutes = (60 * (tot3 - int(tot3)));
cout<< hours<< " hours and "<< minutes<< " minutes."<< endl;
cout<< "press enter to continue...";
cin.get ();
cin.get ();
int main();
}
int main ()
{
top:
cout<< " MENU"<< endl;
cout<< ""<< endl;
cout<< " 1- Delayed Shutdown"<< endl;
cout<< " 2- Find the difference between two times"<< endl;
cout<< "_____________________________________________________________"<< endl;
int strt;
cin>> strt;
//this gets and analyzes input from the user
if (strt == 1)
{
int shutdn ();
int main();
}
if (strt == 2)
{
int diftim ();
int main();
}
else
{
int main();
}
}
|
Im trying to use functions as different "functions". for example: one function executes cod that gets input for subtracting 2 time, another does math that's used multiple times throughout the prgram, etc. Unfortunatly, it doesnt seem to be calling the functions, just ending the program... Can someone help me with this?