C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-17-2009, 09:13 PM   #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.
Ronzel is offline   Reply With Quote
Old 06-18-2009, 07:19 AM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
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.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:41 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22