The headerfile "dos.h" is used to perform some system functions like :
* delay()
* sleep()
* getdate()
* gettime()
* setdate()
* settime()
* sound()
* nosound()
'delay()' and 'sleep()' :
these are two similar functions used to make delay in the ouput of the program.
for example :
#include<iostream.h>
#include<conio.h>
#include<dos.h>
int main()
{
cout<<"This c++ program will exit in 10 seconds.\n";
delay(10000);
return 0;
}
and same thing can be executed through 'sleep(10)'.
'gettime()' and 'getdate()':
these two functions are used to get the time and date of the system in the program.
for example
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
void main()
{
clrscr();
struct date d;
struct time t;
getdate(&d);
gettime(&t);
int day,month,year;
int hour,min,sec;
day=d.da_day;
month=d.da_mon;
year=d.da_year;
hour=t.ti_hour;
min =t.ti_min;
sec= t.ti_sec;
cout<<"The current date is "<<day<<"/"<<month<<"/"<<year<<"\n";
cout<<"The current time is "<<hour<<":"<<min<<":"<<sec<<"\n";
system("pause");
}
output :
The current date is 22/10/2015
The current time is 11:24:05
Press any key to continue.
'setdate()' and 'settime()' :
through these functions we can set the date and time of the system simply using the fuctions:
setdate(&var); and
settime(&var);
note:the members like 'd.da_day' should be integeral always.
'sound()' and 'unsound()':
functions used for adding sound.
example :
#include<dos.h>
void main()
{
for(i=100;i<=1000;i+20)
{
sound(i);
delay(50);
}
unsound();
system("pause");
}

No comments:
Post a Comment