Thread: Local Time Program

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    4

    Local Time Program

    I am trying to create a program that will display the local time of major city throughout the world. The code that I have written so far is

    Code:
    //Local time - Determine the local time for the city given in user input
    
    #include <iostream>
    #include <cstdlib>
    #include <string.h>
    #include <cstdio>
    using namespace std;
    
      int main(int nNumberofArgs, char* pszArgs[])
      {
          
    // Header to program
          
            cout << "**************************************" << endl;
            cout << "**********Local Time Program**********" <<endl;
            cout << "**************************************" << endl << endl;
    
              char dateStr [9];
              char timeStr [9];
              _strdate( dateStr);
    
    // Display the current date and time given on the computer
    
              printf( "The current date is %s \n", dateStr);
             _strtime( timeStr );
             printf( "The current time is %s \n", timeStr);
            cout << endl << endl;
            
    // Ask user for city
            
            string city;
            cout << endl <<  "Enter the city you would like the time for: ";
            cin >> city;
          }
    The problem that I am trying to solve is how to increment or decrement the time based on the time given from the computer.

    Thanks in advance for the help.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read up on
    localtime()
    gmtime()
    mktime()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. little program to get time from log
    By repu1sion in forum C Programming
    Replies: 4
    Last Post: 07-06-2009, 10:05 AM
  2. How to time how long a program takes to run?
    By advancedk in forum C Programming
    Replies: 2
    Last Post: 08-18-2008, 07:50 PM
  3. Creating local variables in a program?
    By fl0at in forum C Programming
    Replies: 5
    Last Post: 01-04-2008, 07:34 PM
  4. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  5. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM