C language library function Daquan (letter B) --- instructions for use)
Source: Internet
Author: User
C language library function Daquan (letter B) --- instructions for use (conversion) -- Linux general technology-Linux programming and kernel information, the following is read details. Function Name: bar
Function: Draw a two-dimensional bar chart
Usage: void far bar (int left, int top, int right, int bottom );
Program example:
# Include
# Include
# Include
# Include
Int main (void)
{
/* Request auto detection */
Int gdriver = DETECT, gmode, errorcode;
Int midx, midy, I;
/* Initialize graphics and local variables */
Initgraph (& gdriver, & gmode ,"");
/* Read result of initialization */
Errorcode = graphresult ();
If (errorcode! = GrOk)/* an error occurred */
{
Printf ("Graphics error: % s \ n", grapherrormsg (errorcode ));
Printf ("Press any key to halt :");
Getch ();
Exit (1);/* terminate with an error code */
}
Midx = getmaxx ()/2;
Midy = getmaxy ()/2;
/* Loop through the fill patterns */
For (I = SOLID_FILL; I {
/* Set the fill style */
Setfillstyle (I, getmaxcolor ());
/* Draw the bar */
Bar (midx-50, midy-50, midx + 50,
Midy + 50 );
Getch ();
}
/* Clean up */
Closegraph ();
Return 0;
}
Function Name: bar3d
Function: Draw a three-dimensional bar chart
Usage: void far bar3d (int left, int top, int right, int bottom,
Int depth, int topflag );
Program example:
# Include
# Include
# Include
# Include
Int main (void)
{
/* Request auto detection */
Int gdriver = DETECT, gmode, errorcode;
Int midx, midy, I;
Int main (void)
{
Int in, out, status, DONE = FALSE;
Bioscom (0, SETTINGS, COM1 );
Cprintf ("... BIOSCOM [ESC] to exit... \ n ");
While (! DONE)
{
Status = bioscom (3, 0, COM1 );
If (status & DATA_READY)
If (out = bioscom (2, 0, COM1) & 0x7F )! = 0)
Putch (out );
If (kbhit ())
{
If (in = getch () = '\ x1B ')
DONE = TRUE;
Bioscom (1, in, COM1 );
}
}
Return 0;
}
Function Name: biosdisk
Function: Hard Disk I/O
Usage: int biosdisk (int cmd, int drive, int head, int track, int sector
Int nsects, void * buffer );
Program example:
# Include
# Include
Int main (void)
{
Int result;
Char buffer [512];
Printf ("Testing to see if drive a: is ready \ n ");
Result = biosdisk (, buffer );
Result & = 0x02;
(Result )? (Printf ("Drive A: Ready \ n ")):
(Printf ("Drive A: Not Ready \ n "));
Return 0;
}
Function Name: biosequip
Skill: Check the device
Usage: int biosequip (void );
Program example:
# Include
# Include
Int main (void)
{
Int result;
Char buffer [512];
Printf ("Testing to see if drive a: is ready \ n ");
Result = biosdisk (, buffer );
Result & = 0x02;
(Result )? (Printf ("Drive A: Ready \ n ")):
(Printf ("Drive A: Not Ready \ n "));
Return 0;
}
Function Name: bioskey
Function: Use the keyboard interface of the BIOS service directly.
Usage: int bioskey (int cmd );
Program example:
# Include
# Include
# Include
# Define RIGHT 0x01
# Define LEFT 0x02
# Define CTRL 0x04
# Define ALT 0x08
Int main (void)
{
Int key, modifiers;
/* Function 1 returns 0 until a key is pressed */
While (bioskey (1) = 0 );
/* Function 0 returns the key that is waiting */
Key = bioskey (0 );
/* Use function 2 to determine if shift keys were used */
Modifiers = bioskey (2 );
If (modifiers)
{
Printf ("[");
If (modifiers & RIGHT) printf ("RIGHT ");
If (modifiers & LEFT) printf ("LEFT ");
If (modifiers & CTRL) printf ("CTRL ");
If (modifiers & ALT) printf ("ALT ");
Printf ("]");
}
/* Print out the character read */
If (isalnum (key & 0xFF ))
Printf ("'% C' \ n", key );
Else
Printf ("% # 02x \ n", key );
Return 0;
}
Function Name: biosmemory
Function: return the size of the storage block.
Usage: int biosmemory (void );
Program example:
# Include
# Include
Int main (void)
{
Int memory_size;
Memory_size = biosmemory ();/* returns value up to 640 K */
Printf ("RAM size = % dK \ n", memory_size );
Return 0;
}
Function Name: biosprint
Power: directly use the BIOS service printer I/O
Usage: int biosprint (int cmd, int byte, int port );
Program example:
# Include
# Include
# Include
Int main (void)
{
# Define STATUS 2/* printer status command */
# Define PORTNUM 0/* port number for LPT1 */
Int status, abyte = 0;
Printf ("Please turn off your printer. Press any key to continue \ n ");
Getch ();
Status = biosprint (STATUS, abyte, PORTNUM );
If (status & 0x01)
Printf ("Device time out. \ n ");
If (status & 0x08)
Printf ("I/O error. \ n ");
If (status & 0x10)
Printf ("Selected. \ n ");
If (status & 0x20)
Printf ("Out of paper. \ n ");
If (status & 0x40)
Printf ("Acknowledge. \ n ");
If (status & 0x80)
Printf ("Not busy. \ n ");
Return 0;
}
Function Name: biostime
Function: read or set the BIOS time.
Usage: long biostime (int cmd, long newtime );
Program example:
# Include
# Include
# Include
# Include
Int main (void)
{
Long bios_time;
Clrscr ();
Cprintf ("The number of clock ticks since midnight is: \ r \ n ");
Cprintf ("The number of seconds since midnight is: \ r \ n ");
Cprintf ("The number of minutes since midnight is: \ r \ n ");
Cprintf ("The number of hours since midnight is: \ r \ n ");
Cprintf ("\ r \ nPress any key to quit :");
While (! Kbhit ())
{
Bios_time = biostime (0, 0L );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.