8-8.c

来自「< c程序员成长攻略>>源代码,一本很好的书,原书全部的代码都」· C语言 代码 · 共 48 行

C
48
字号
#include"dos.h"
#include"conio.h"
int SetDate()
{
	union REGS inregs,outregs;
	inregs.h.ah=0x2B;
	inregs.x.cx=1983;
	inregs.h.dh=8;
	inregs.h.dl=14;
	intdos(&inregs,&outregs);
	return outregs.h.al;
}

void GetDate()
{
	int year,month,day;
	union REGS inregs,outregs;
	inregs.h.ah=0x2A;
	intdos(&inregs,&outregs);
	year=outregs.x.cx;
	month=outregs.h.dh;
	day=outregs.h.dl;
	gotoxy(30,10);
	printf("%4d.%2d.%2d",year,month,day);
}

void GetTime()
{
	int hour,min,sec;
	union REGS inregs,outregs;
	inregs.h.ah=0x2C;
	intdos(&inregs,&outregs);
	hour=outregs.h.ch;
	min=outregs.h.cl;
	sec=outregs.h.dh;
	gotoxy(30,12);
	printf("%2d:%2d:%2d",hour,min,sec);
}

main()
{
	clrscr();
	SetDate();
	GetDate();
	GetTime();
	getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?