-
time.h help
hi i am trying to get my feet wet by trying some of the older assignments of a class that i plan to take.
the link to the assignment is here http://www.cs.uh.edu/~svenkat/lib/as...r2002/ASSIGN1/
i have planned a pseudocode of sort, but how do i implement time.h (have never worked with that), since many of the functions are time related........any hinters or help will be greatly appreciated.
-
You don't need to implement <time.h>. You just use the functions and types provided there in. You only need to implement the CoffeeMaker class and the member functions: getCoffee(), getVolume(), and refill(). Put the class in the file "CoffeeMaker.h".
He's giving you everything you need... he wants to see if you can put the words into code.
-
yeah, but time.h is included and there is a mention of time taken for each process, and how one function cant be called if the other is still on.
-
aah thanks alot,
yes this professor believes in void main alot, it is scary, thanks for the help, if i have any more trouble i will right back.
so for this
next_available_time = now + calculated_coffee_machine_delay
what type of variables do i use.....and how do i add those delay to the time
-
why?
why would someone use void main???
isn't void to skip a function ?
-
void means that the function will not return anything.......if you look in the FAQ the use of void main is looked down upon and for the right reasons......still the open question, what variable type to i use to store the time, add time etc
-
http://www.cplusplus.com/ref/ctime/index.html
There are 3 date/time data types in the c/c++ standard libraries.
clock_t : when returned by clock() it show # of ticks since process start
time_t : when returned by time() it shows # of seconds since January 1, 1970 UTC 00:00 hours.
tm : the basic date/time struct that you can use to add/substract You will have to write your own functions for that.
Note that you can freely convert time_t to tm and vice versa using the gmtime() and mktime() functions.
And since this is C++, use the newer headers:
Code:
#include <ctime>
using namespace std;