load and time

dears

i need an axample how to get time and how to load numbers from file in the disk

i found this in the help but it is not printing

#include
#include

int main(void)
{
struct time t;

gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d
",
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
return 0;
}

i replaced printf by cout then the statment is printed but the time no

pls help

thanks

Comments

  • : dears
    :
    : i need an axample how to get time and how to load numbers from file in the disk
    :
    : i found this in the help but it is not printing
    :
    : #include
    : #include
    :
    : int main(void)
    : {
    : struct time t;
    :
    : gettime(&t);
    : printf("The current time is: %2d:%02d:%02d.%02d
    ",
    : t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
    : return 0;
    : }
    :
    : i replaced printf by cout then the statment is printed but the time no
    :
    : pls help
    :
    : thanks
    :
    :

    Use TDateTime:

    TDateTime time;
    AnsiString current_time=time.CurrentDateTime().DateTimeString();
  • I found this example it is working
    #include
    #include
    #include
    #include

    int main(void)
    {
    FILE *stream;
    std::ftime ft;
    int h,m,s,ms;
    if ((stream = fopen("TEST.$$$","wt")) == NULL)
    { fprintf(stderr, "Cannot open output file.
    "); return 1; }
    getftime(fileno(stream), &ft);
    h=ft.ft_hour; m=ft.ft_min; s=ft.ft_tsec;
    printf("File time: %u:%u:%u
    ",h,m,s);
    printf("File date: %u/%u/%u
    ",
    ft.ft_month, ft.ft_day,ft.ft_year+1980);
    fclose(stream);
    cout << "

    Press any key to continue";
    getch(); // wait for key pressure
    return 0;
    }
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories