Thread: time.h help

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    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.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    78
    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.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    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.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    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
    Last edited by noob2c; 07-10-2003 at 08:12 AM.

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    42

    why?

    why would someone use void main???

    isn't void to skip a function ?
    I have a code which stops life!

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    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

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    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;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. time.h
    By zensatori in forum C Programming
    Replies: 28
    Last Post: 04-15-2007, 06:39 PM
  2. Help with time.h functions please.
    By Ifurita. in forum C++ Programming
    Replies: 4
    Last Post: 05-20-2003, 03:58 AM
  3. time.h and miliseconds question
    By Diamonds in forum C++ Programming
    Replies: 10
    Last Post: 12-16-2002, 08:41 AM
  4. Replies: 2
    Last Post: 10-18-2002, 08:30 AM
  5. a time.h problem
    By Max in forum C Programming
    Replies: 14
    Last Post: 10-15-2002, 02:43 PM