Thread: Comparing two time programs

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Kayoss's Avatar
    Join Date
    Sep 2005
    Location
    California
    Posts
    53

    Comparing two time programs

    Okay, this simple program works just fine:
    Code:
    #include <iostrem>
    #include <ctime>
    using namespace std;
    
    int main()
    {
    
      time_t myTime;
      time ( &myTime );
      printf ( "Current date and time are: %s", ctime (&myTime) );
    
     return 0;
    }
    Yet this one doesn't (it compiles but doesn't return anything):
    Code:
    #include <iostream>
    #include <ctime> 
    using namespace std;
    
    class Date 
    {
       public:
          Date();  
          ~Date();  
    	
       private:
          int myTime;
    
    
    }; // end class Date
    
    Date::Date()
    {
      time_t myTime;
      time ( &myTime );
      printf ( "Current date and time are: %s", ctime (&myTime) );
    }
    
    int main(){
    
       Date h();
      
       return 0;
    }
    As you can see, I'm trying to create a constructor to do the same thing that the first program does. Any info is greatly appreciated!
    Last edited by Kayoss; 04-10-2006 at 02:10 PM.
    THE redheaded stepchild.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Execution Time - Rijandael encryption
    By gamer4life687 in forum C++ Programming
    Replies: 5
    Last Post: 09-20-2008, 09:25 PM
  2. Journey time prog 1 minute wrong
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 10-12-2006, 03:41 AM
  3. The new FAQ
    By Hammer in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 08-30-2006, 10:05 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM