Reports the free disk space on a DOS system
#include <stdio.h>
#include <dos.h>
void main(void)
{
struct dfree diskinfo;
long disk_space;
getdfree(3, &diskinfo);
disk_space = (long) diskinfo.df_avail * (long) diskinfo.df_bsec * (long) diskinfo.df_sclus;
printf(“Available disk space %ld\n”, disk_space);
}
Bookmark It
Hide Sites
$$(‘div.d134′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });
This shows the difftime function and in this case we will pause our program for 5 seconds with it
#include <stdio.h>
#include <time.h>
int main()
{
time_t start;
time_t current;
time(&start);
printf(“delay for 5 seconds.\n”);
do{
time(¤t);
}while(difftime(current,start) < 5.0);
printf(“Finished delay.\n”);
return 0;
}
Bookmark It
Hide Sites
$$(‘div.d131′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });
Using the Ctime function
This example shows a sample usage for the Ctime function to display the date and time.
/*using the ctime function*/
#include <stdio.h>
#include <time.h>
int main()
{
time_t tm;
tm = time(NULL);
printf(ctime(&tm));
return 0;
}
This was tested on Visual C++ 6 and LCC Win 32
Bookmark It
Hide Sites
$$(‘div.d128′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
int menu(void);
main()
{
while(1)
{
/*get selection and execute the relevant statement*/
switch(menu())
{
case 1:
{
puts(“sound the speaker 1\n”);
sound(2000);
sleep(2);
nosound();
break;
}
case 2:
{
puts(“sound that speaker 2\n”);
sound(4000);
sleep(2);
nosound();
break;
}
case 3:
{
puts(“You are quitting\n”);
exit(0);
break;
}
default:
{
puts(“Invalid menu choice\n”);
break;
}
}
}
return 0;
}
/*menu function*/
int menu(void)
{
int reply;
/*display menu options*/
puts(“Enter 1 for beep 1.\n”);
puts(“Enter 2 for beep 2.\n”);
puts(“Enter 3 to quit.\n”);
/*scan for user entry*/
scanf(“%d”, &reply);
return reply;
}
Should work with most compilers
Bookmark It
Hide Sites
$$(‘div.d125′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) [...]