Date and Time Function

Discussion in 'C Programming' started by newbie@C, Nov 9, 2003.

  1. newbie@C

    newbie@C Guest

    Greetings,

    I would like to add a date/time function to a program. I would like to be
    able to do something like this:

    total=age*365+(current date as per users system clock)

    See below for the code so far (yes, I am brand spanking new) -

    Thanks.

    /* Age Converter */
    /* age.c */
    /* Created on November 8, 2003 */

    main()
    {
    int age,total;
    char name[20];

    printf("Hello.\n");
    printf("\n");
    printf("Welcome to my Age Converter!\n");
    printf("\n");
    printf("What is your name?\n");
    scanf("%s",&name);
    printf("\n");
    printf("O.K. %s, enter your age in years and I'll convert it into
    days:",name);
    scanf("%d",&age);
    total=age*365;
    printf("\n");
    printf("Your age in days is %d",total);
    printf("\n");
    }
    ---
    "I wanted to do good without fuss, for I found, that fuss does no good and
    that the good makes no fuss."

    Louis-Claude de Saint-Martin.
    The Unknown Philosopher
     
    newbie@C, Nov 9, 2003
    #1
    1. Advertising

  2. On Sun, 9 Nov 2003 12:57:10 -0500, in comp.lang.c , "newbie@C"
    <> wrote:

    >Greetings,
    >
    >I would like to add a date/time function to a program. I would like to be
    >able to do something like this:
    >
    > total=age*365+(current date as per users system clock)


    you will find the functions and structures listed in time.h useful.


    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, Nov 9, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    631
    Matthew Speed
    Nov 8, 2003
  2. Chris Berg
    Replies:
    0
    Views:
    828
    Chris Berg
    Oct 27, 2003
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,327
    Michael Borgwardt
    May 30, 2004
  4. Keith Cochrane
    Replies:
    2
    Views:
    635
    Keith Cochrane
    Aug 6, 2006
  5. Summu82
    Replies:
    5
    Views:
    890
    Richard Heathfield
    Jun 7, 2006
Loading...

Share This Page