|
From: Per W. <pw...@ia...> - 2003-02-05 14:32:09
|
If you look into dos.h, you'll notice that it doesn't contain any time
handling functions or structures, so obviously the compiler doesn't have
the faintest what "struct dos_date_t" is.
If you on the other hand take a look into time.h, you'll find a lot of
standard time-handling functions and structures there.
#include <iostream>
#include <time.h>
time_t t;
struct tm *local;
// alt 1
t = time(NULL);
cout << ctime(&t);
// alt 2
t = time(NULL);
local = localtime(&t);
std::cout << "local time is " << asctime(local);
std::cout << "gmt time is " << asctime(gmtime(&t));
std::cout << "current year is " << localtime.tm_year;
/Per W
On Wed, 5 Feb 2003, Dondolo Mpho wrote:
> Hi all,
>
> Can anybody tell me what I am doing wrong. I get an error
> "aggregate struct dos_date_t today has incomplete type and cannot be
> initialised."
>
> can some one please help me reconstruct the syntax
>
>
> //program displaying the date and time
> //
>
> #include<iostream.h>
> #include<stdlib.h>
> #include<dos.h>
>
> main()
> {
> struct dos_date_t today;
> struct dos_time_t theTime;
>
> dos_getdate( &today );
> cout<<"The date is "<<(int)today.month
> <<"/"<<(int)today.day<<"/"<<today.year<<"\n";
>
> dos_gettime( &theTime);
> cout<<"The time is "<<(int)theTime.hour<<":";
>
> if(theTime.minute<10)
> cout<<'0';
> cout<<(int)theTime.minute<<":";
>
> if(theTime.seconds<10)
> cout<<'0';
> cout<<(int)theTime.seconds<<"\n";
>
> system("PAUSE");
> return 0;
> }
> Mpho Dondolo
> Support Analyst
> CSC Computer Sciences (South Africa) (Pty) Ltd
> Tel: +27 21 5030056
> Cell: +27 84 3371468
> Fax: +27 21 5095619
> Email:MDo...@ol...
> Email: MDo...@cs...
>
> "How do you claim to have loved,
> when you have never loved unconditionally"
>
>
>
>
|